Merge branch 'gitee-master' into gitlab-upstream

This commit is contained in:
zhengshuxin 2024-01-31 11:57:06 +08:00
commit 58285f06f5
3 changed files with 20 additions and 9 deletions

View File

@ -29,14 +29,19 @@ void event_check_fds(ACL_EVENT *ev)
fdp->event_type |= ACL_EVENT_READ;
fdp->fdidx_ready = ev->ready_cnt;
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->fdidx_ready = ev->ready_cnt;
ev->ready[ev->ready_cnt++] = fdp;
} else if (fdp->r_ttl > 0 && ev->present > fdp->r_ttl) {
fdp->stream->read_ready = 0;
fdp->event_type |= ACL_EVENT_RW_TIMEOUT;
fdp->fdidx_ready = ev->ready_cnt;
ev->ready[ev->ready_cnt++] = fdp;
} else {
fdp->stream->read_ready = 0;
}
} else if ((fdp->flag & EVENT_FDTABLE_FLAG_WRITE)) {
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;
ev->ready[ev->ready_cnt++] = fdp;
} 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->fdidx_ready = ev->ready_cnt;
ev->ready[ev->ready_cnt++] = fdp;
@ -78,11 +87,14 @@ int event_prepare(ACL_EVENT *ev)
fdp->fdidx_ready = ev->ready_cnt;
ev->ready[ev->ready_cnt++] = fdp;
} else if (fdp->r_ttl > 0 && ev->present > fdp->r_ttl) {
fdp->stream->read_ready = 0;
fdp->event_type |= ACL_EVENT_RW_TIMEOUT;
fdp->fdidx_ready = ev->ready_cnt;
ev->ready[ev->ready_cnt++] = fdp;
} else
} else {
fdp->stream->read_ready = 0;
nwait++;
}
} else if ((fdp->flag & EVENT_FDTABLE_FLAG_WRITE)) {
if (fdp->w_ttl > 0 && ev->present > fdp->w_ttl) {
fdp->event_type |= ACL_EVENT_RW_TIMEOUT;

View File

@ -923,9 +923,6 @@ static void dispatch_receive(int event_type acl_unused, ACL_EVENT *event,
acl_msg_fatal("%s(%d), %s: conn invalid",
__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);
if (ret <= 0 || fd < 0) {
acl_msg_warn("%s(%d), %s: read from master_dispatch(%s) error %s",

View File

@ -37,9 +37,11 @@ int acl_peekfd(ACL_SOCKET fd)
* Anticipate a series of system-dependent code fragments.
*/
#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)
return (ioctlsocket(fd, FIONREAD, (unsigned long *) &count) < 0
? -1 : count);
return ioctlsocket(fd, FIONREAD, (unsigned long *) &count) < 0
? -1 : count;
#else
return 0;
#endif
}