mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-13 16:35:35 +08:00
Merge branch 'gitee-master' into gitlab-upstream
This commit is contained in:
commit
58285f06f5
@ -29,14 +29,19 @@ void event_check_fds(ACL_EVENT *ev)
|
|||||||
fdp->event_type |= ACL_EVENT_READ;
|
fdp->event_type |= ACL_EVENT_READ;
|
||||||
fdp->fdidx_ready = ev->ready_cnt;
|
fdp->fdidx_ready = ev->ready_cnt;
|
||||||
ev->ready[ev->ready_cnt++] = fdp;
|
ev->ready[ev->ready_cnt++] = fdp;
|
||||||
} else if (fdp->stream->read_ready && !fdp->listener) {
|
} else if (fdp->stream->read_ready && !fdp->listener
|
||||||
|
&& acl_peekfd(ACL_VSTREAM_SOCK(fdp->stream)) > 0) {
|
||||||
fdp->event_type |= ACL_EVENT_READ;
|
fdp->event_type |= ACL_EVENT_READ;
|
||||||
fdp->fdidx_ready = ev->ready_cnt;
|
fdp->fdidx_ready = ev->ready_cnt;
|
||||||
ev->ready[ev->ready_cnt++] = fdp;
|
ev->ready[ev->ready_cnt++] = fdp;
|
||||||
} else if (fdp->r_ttl > 0 && ev->present > fdp->r_ttl) {
|
} else if (fdp->r_ttl > 0 && ev->present > fdp->r_ttl) {
|
||||||
|
fdp->stream->read_ready = 0;
|
||||||
fdp->event_type |= ACL_EVENT_RW_TIMEOUT;
|
fdp->event_type |= ACL_EVENT_RW_TIMEOUT;
|
||||||
fdp->fdidx_ready = ev->ready_cnt;
|
fdp->fdidx_ready = ev->ready_cnt;
|
||||||
ev->ready[ev->ready_cnt++] = fdp;
|
ev->ready[ev->ready_cnt++] = fdp;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
fdp->stream->read_ready = 0;
|
||||||
}
|
}
|
||||||
} else if ((fdp->flag & EVENT_FDTABLE_FLAG_WRITE)) {
|
} else if ((fdp->flag & EVENT_FDTABLE_FLAG_WRITE)) {
|
||||||
if (fdp->w_ttl > 0 && ev->present > fdp->w_ttl) {
|
if (fdp->w_ttl > 0 && ev->present > fdp->w_ttl) {
|
||||||
@ -68,7 +73,11 @@ int event_prepare(ACL_EVENT *ev)
|
|||||||
fdp->fdidx_ready = ev->ready_cnt;
|
fdp->fdidx_ready = ev->ready_cnt;
|
||||||
ev->ready[ev->ready_cnt++] = fdp;
|
ev->ready[ev->ready_cnt++] = fdp;
|
||||||
} else if ((fdp->flag & EVENT_FDTABLE_FLAG_READ)) {
|
} else if ((fdp->flag & EVENT_FDTABLE_FLAG_READ)) {
|
||||||
if (fdp->stream->read_ready && !fdp->listener) {
|
/* If the read_ready has been set, we should check
|
||||||
|
* if the fd can be readable first.
|
||||||
|
*/
|
||||||
|
if (fdp->stream->read_ready && !fdp->listener
|
||||||
|
&& acl_peekfd(sockfd) > 0) {
|
||||||
fdp->event_type |= ACL_EVENT_READ;
|
fdp->event_type |= ACL_EVENT_READ;
|
||||||
fdp->fdidx_ready = ev->ready_cnt;
|
fdp->fdidx_ready = ev->ready_cnt;
|
||||||
ev->ready[ev->ready_cnt++] = fdp;
|
ev->ready[ev->ready_cnt++] = fdp;
|
||||||
@ -78,11 +87,14 @@ int event_prepare(ACL_EVENT *ev)
|
|||||||
fdp->fdidx_ready = ev->ready_cnt;
|
fdp->fdidx_ready = ev->ready_cnt;
|
||||||
ev->ready[ev->ready_cnt++] = fdp;
|
ev->ready[ev->ready_cnt++] = fdp;
|
||||||
} else if (fdp->r_ttl > 0 && ev->present > fdp->r_ttl) {
|
} else if (fdp->r_ttl > 0 && ev->present > fdp->r_ttl) {
|
||||||
|
fdp->stream->read_ready = 0;
|
||||||
fdp->event_type |= ACL_EVENT_RW_TIMEOUT;
|
fdp->event_type |= ACL_EVENT_RW_TIMEOUT;
|
||||||
fdp->fdidx_ready = ev->ready_cnt;
|
fdp->fdidx_ready = ev->ready_cnt;
|
||||||
ev->ready[ev->ready_cnt++] = fdp;
|
ev->ready[ev->ready_cnt++] = fdp;
|
||||||
} else
|
} else {
|
||||||
|
fdp->stream->read_ready = 0;
|
||||||
nwait++;
|
nwait++;
|
||||||
|
}
|
||||||
} else if ((fdp->flag & EVENT_FDTABLE_FLAG_WRITE)) {
|
} else if ((fdp->flag & EVENT_FDTABLE_FLAG_WRITE)) {
|
||||||
if (fdp->w_ttl > 0 && ev->present > fdp->w_ttl) {
|
if (fdp->w_ttl > 0 && ev->present > fdp->w_ttl) {
|
||||||
fdp->event_type |= ACL_EVENT_RW_TIMEOUT;
|
fdp->event_type |= ACL_EVENT_RW_TIMEOUT;
|
||||||
|
@ -923,9 +923,6 @@ static void dispatch_receive(int event_type acl_unused, ACL_EVENT *event,
|
|||||||
acl_msg_fatal("%s(%d), %s: conn invalid",
|
acl_msg_fatal("%s(%d), %s: conn invalid",
|
||||||
__FUNCTION__, __LINE__, myname);
|
__FUNCTION__, __LINE__, myname);
|
||||||
|
|
||||||
/* XXX: Must reset the read_ready flag been set in event trigger */
|
|
||||||
conn->read_ready = 0;
|
|
||||||
|
|
||||||
ret = acl_read_fd(ACL_VSTREAM_SOCK(conn), buf, sizeof(buf) - 1, &fd);
|
ret = acl_read_fd(ACL_VSTREAM_SOCK(conn), buf, sizeof(buf) - 1, &fd);
|
||||||
if (ret <= 0 || fd < 0) {
|
if (ret <= 0 || fd < 0) {
|
||||||
acl_msg_warn("%s(%d), %s: read from master_dispatch(%s) error %s",
|
acl_msg_warn("%s(%d), %s: read from master_dispatch(%s) error %s",
|
||||||
|
@ -37,9 +37,11 @@ int acl_peekfd(ACL_SOCKET fd)
|
|||||||
* Anticipate a series of system-dependent code fragments.
|
* Anticipate a series of system-dependent code fragments.
|
||||||
*/
|
*/
|
||||||
#ifdef ACL_UNIX
|
#ifdef ACL_UNIX
|
||||||
return (ioctl(fd, FIONREAD, (char *) &count) < 0 ? -1 : count);
|
return ioctl(fd, FIONREAD, (char *) &count) < 0 ? -1 : count;
|
||||||
#elif defined(ACL_WINDOWS)
|
#elif defined(ACL_WINDOWS)
|
||||||
return (ioctlsocket(fd, FIONREAD, (unsigned long *) &count) < 0
|
return ioctlsocket(fd, FIONREAD, (unsigned long *) &count) < 0
|
||||||
? -1 : count);
|
? -1 : count;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user