[MEDIUM] pollers: store the events in arrays

Instead of managing StaticReadEvent/StaticWriteEvent, use evts[dir]
This commit is contained in:
Willy Tarreau 2007-04-08 17:42:27 +02:00
parent 663193882a
commit 28d86862bc
3 changed files with 99 additions and 188 deletions

View File

@ -34,8 +34,8 @@ _syscall4 (int, epoll_wait, int, epfd, struct epoll_event *, events, int, maxeve
#endif #endif
static fd_set *StaticReadEvent, *StaticWriteEvent; static fd_set *fd_evts[2];
static fd_set *PrevReadEvent, *PrevWriteEvent; static fd_set *old_evts[2];
/* private data */ /* private data */
static struct epoll_event *epoll_events; static struct epoll_event *epoll_events;
@ -49,79 +49,49 @@ static int epoll_fd;
*/ */
REGPRM2 static int __fd_isset(const int fd, const int dir) REGPRM2 static int __fd_isset(const int fd, const int dir)
{ {
fd_set *ev; return FD_ISSET(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
return FD_ISSET(fd, ev);
} }
REGPRM2 static void __fd_set(const int fd, const int dir) REGPRM2 static void __fd_set(const int fd, const int dir)
{ {
fd_set *ev; FD_SET(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
FD_SET(fd, ev);
} }
REGPRM2 static void __fd_clr(const int fd, const int dir) REGPRM2 static void __fd_clr(const int fd, const int dir)
{ {
fd_set *ev; FD_CLR(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
FD_CLR(fd, ev);
} }
REGPRM2 static int __fd_cond_s(const int fd, const int dir) REGPRM2 static int __fd_cond_s(const int fd, const int dir)
{ {
int ret; int ret;
fd_set *ev; ret = !FD_ISSET(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
ret = !FD_ISSET(fd, ev);
if (ret) if (ret)
FD_SET(fd, ev); FD_SET(fd, fd_evts[dir]);
return ret; return ret;
} }
REGPRM2 static int __fd_cond_c(const int fd, const int dir) REGPRM2 static int __fd_cond_c(const int fd, const int dir)
{ {
int ret; int ret;
fd_set *ev; ret = FD_ISSET(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
ret = FD_ISSET(fd, ev);
if (ret) if (ret)
FD_CLR(fd, ev); FD_CLR(fd, fd_evts[dir]);
return ret; return ret;
} }
REGPRM1 static void __fd_rem(const int fd) REGPRM1 static void __fd_rem(const int fd)
{ {
FD_CLR(fd, StaticReadEvent); FD_CLR(fd, fd_evts[DIR_RD]);
FD_CLR(fd, StaticWriteEvent); FD_CLR(fd, fd_evts[DIR_WR]);
} }
REGPRM1 static void __fd_clo(const int fd) REGPRM1 static void __fd_clo(const int fd)
{ {
FD_CLR(fd, StaticReadEvent); FD_CLR(fd, fd_evts[DIR_RD]);
FD_CLR(fd, StaticWriteEvent); FD_CLR(fd, fd_evts[DIR_WR]);
FD_CLR(fd, PrevReadEvent); FD_CLR(fd, old_evts[DIR_RD]);
FD_CLR(fd, PrevWriteEvent); FD_CLR(fd, old_evts[DIR_WR]);
} }
@ -149,26 +119,26 @@ REGPRM1 static int epoll_init(struct poller *p)
if (epoll_events == NULL) if (epoll_events == NULL)
goto fail_ee; goto fail_ee;
if ((PrevReadEvent = (fd_set *)calloc(1, fd_set_bytes)) == NULL) if ((old_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
goto fail_prevt; goto fail_prevt;
if ((PrevWriteEvent = (fd_set *)calloc(1, fd_set_bytes)) == NULL) if ((old_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
goto fail_pwevt; goto fail_pwevt;
if ((StaticReadEvent = (fd_set *)calloc(1, fd_set_bytes)) == NULL) if ((fd_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
goto fail_srevt; goto fail_srevt;
if ((StaticWriteEvent = (fd_set *)calloc(1, fd_set_bytes)) == NULL) if ((fd_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
goto fail_swevt; goto fail_swevt;
return 1; return 1;
fail_swevt: fail_swevt:
free(StaticReadEvent); free(fd_evts[DIR_RD]);
fail_srevt: fail_srevt:
free(PrevWriteEvent); free(old_evts[DIR_WR]);
fail_pwevt: fail_pwevt:
free(PrevReadEvent); free(old_evts[DIR_RD]);
fail_prevt: fail_prevt:
free(epoll_events); free(epoll_events);
fail_ee: fail_ee:
@ -185,17 +155,17 @@ REGPRM1 static int epoll_init(struct poller *p)
*/ */
REGPRM1 static void epoll_term(struct poller *p) REGPRM1 static void epoll_term(struct poller *p)
{ {
if (StaticWriteEvent) if (fd_evts[DIR_WR])
free(StaticWriteEvent); free(fd_evts[DIR_WR]);
if (StaticReadEvent) if (fd_evts[DIR_RD])
free(StaticReadEvent); free(fd_evts[DIR_RD]);
if (PrevWriteEvent) if (old_evts[DIR_WR])
free(PrevWriteEvent); free(old_evts[DIR_WR]);
if (PrevReadEvent) if (old_evts[DIR_RD])
free(PrevReadEvent); free(old_evts[DIR_RD]);
if (epoll_events) if (epoll_events)
free(epoll_events); free(epoll_events);
@ -222,8 +192,8 @@ REGPRM2 static void epoll_poll(struct poller *p, int wait_time)
for (fds = 0; (fds << INTBITS) < maxfd; fds++) { for (fds = 0; (fds << INTBITS) < maxfd; fds++) {
rn = ((int*)StaticReadEvent)[fds]; ro = ((int*)PrevReadEvent)[fds]; rn = ((int*)fd_evts[DIR_RD])[fds]; ro = ((int*)old_evts[DIR_RD])[fds];
wn = ((int*)StaticWriteEvent)[fds]; wo = ((int*)PrevWriteEvent)[fds]; wn = ((int*)fd_evts[DIR_WR])[fds]; wo = ((int*)old_evts[DIR_WR])[fds];
if ((ro^rn) | (wo^wn)) { if ((ro^rn) | (wo^wn)) {
for (count = 0, fd = fds << INTBITS; count < (1<<INTBITS) && fd < maxfd; count++, fd++) { for (count = 0, fd = fds << INTBITS; count < (1<<INTBITS) && fd < maxfd; count++, fd++) {
@ -243,10 +213,10 @@ REGPRM2 static void epoll_poll(struct poller *p, int wait_time)
sw = FD_ISSET(fd&((1<<INTBITS)-1), (typeof(fd_set*))&wn); sw = FD_ISSET(fd&((1<<INTBITS)-1), (typeof(fd_set*))&wn);
#endif #endif
#else #else
pr = FD_ISSET(fd, PrevReadEvent); pr = FD_ISSET(fd, old_evts[DIR_RD]);
pw = FD_ISSET(fd, PrevWriteEvent); pw = FD_ISSET(fd, old_evts[DIR_WR]);
sr = FD_ISSET(fd, StaticReadEvent); sr = FD_ISSET(fd, fd_evts[DIR_RD]);
sw = FD_ISSET(fd, StaticWriteEvent); sw = FD_ISSET(fd, fd_evts[DIR_WR]);
#endif #endif
if (!((sr^pr) | (sw^pw))) if (!((sr^pr) | (sw^pw)))
continue; continue;
@ -296,8 +266,8 @@ REGPRM2 static void epoll_poll(struct poller *p, int wait_time)
} }
#endif // EPOLL_CTL_MOD_WORKAROUND #endif // EPOLL_CTL_MOD_WORKAROUND
} }
((int*)PrevReadEvent)[fds] = rn; ((int*)old_evts[DIR_RD])[fds] = rn;
((int*)PrevWriteEvent)[fds] = wn; ((int*)old_evts[DIR_WR])[fds] = wn;
} }
} }
@ -308,14 +278,14 @@ REGPRM2 static void epoll_poll(struct poller *p, int wait_time)
for (count = 0; count < status; count++) { for (count = 0; count < status; count++) {
fd = epoll_events[count].data.fd; fd = epoll_events[count].data.fd;
if (FD_ISSET(fd, StaticReadEvent)) { if (FD_ISSET(fd, fd_evts[DIR_RD])) {
if (fdtab[fd].state == FD_STCLOSE) if (fdtab[fd].state == FD_STCLOSE)
continue; continue;
if (epoll_events[count].events & ( EPOLLIN | EPOLLERR | EPOLLHUP )) if (epoll_events[count].events & ( EPOLLIN | EPOLLERR | EPOLLHUP ))
fdtab[fd].cb[DIR_RD].f(fd); fdtab[fd].cb[DIR_RD].f(fd);
} }
if (FD_ISSET(fd, StaticWriteEvent)) { if (FD_ISSET(fd, fd_evts[DIR_WR])) {
if (fdtab[fd].state == FD_STCLOSE) if (fdtab[fd].state == FD_STCLOSE)
continue; continue;
if (epoll_events[count].events & ( EPOLLOUT | EPOLLERR | EPOLLHUP )) if (epoll_events[count].events & ( EPOLLOUT | EPOLLERR | EPOLLHUP ))

View File

@ -26,7 +26,7 @@
#include <proto/task.h> #include <proto/task.h>
static fd_set *StaticReadEvent, *StaticWriteEvent; static fd_set *fd_evts[2];
/* private data */ /* private data */
static struct pollfd *poll_events = NULL; static struct pollfd *poll_events = NULL;
@ -39,71 +39,41 @@ static struct pollfd *poll_events = NULL;
*/ */
REGPRM2 static int __fd_isset(const int fd, const int dir) REGPRM2 static int __fd_isset(const int fd, const int dir)
{ {
fd_set *ev; return FD_ISSET(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
return FD_ISSET(fd, ev);
} }
REGPRM2 static void __fd_set(const int fd, const int dir) REGPRM2 static void __fd_set(const int fd, const int dir)
{ {
fd_set *ev; FD_SET(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
FD_SET(fd, ev);
} }
REGPRM2 static void __fd_clr(const int fd, const int dir) REGPRM2 static void __fd_clr(const int fd, const int dir)
{ {
fd_set *ev; FD_CLR(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
FD_CLR(fd, ev);
} }
REGPRM2 static int __fd_cond_s(const int fd, const int dir) REGPRM2 static int __fd_cond_s(const int fd, const int dir)
{ {
int ret; int ret;
fd_set *ev; ret = !FD_ISSET(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
ret = !FD_ISSET(fd, ev);
if (ret) if (ret)
FD_SET(fd, ev); FD_SET(fd, fd_evts[dir]);
return ret; return ret;
} }
REGPRM2 static int __fd_cond_c(const int fd, const int dir) REGPRM2 static int __fd_cond_c(const int fd, const int dir)
{ {
int ret; int ret;
fd_set *ev; ret = FD_ISSET(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
ret = FD_ISSET(fd, ev);
if (ret) if (ret)
FD_CLR(fd, ev); FD_CLR(fd, fd_evts[dir]);
return ret; return ret;
} }
REGPRM1 static void __fd_rem(const int fd) REGPRM1 static void __fd_rem(const int fd)
{ {
FD_CLR(fd, StaticReadEvent); FD_CLR(fd, fd_evts[DIR_RD]);
FD_CLR(fd, StaticWriteEvent); FD_CLR(fd, fd_evts[DIR_WR]);
} }
@ -127,16 +97,16 @@ REGPRM1 static int poll_init(struct poller *p)
if (poll_events == NULL) if (poll_events == NULL)
goto fail_pe; goto fail_pe;
if ((StaticReadEvent = (fd_set *)calloc(1, fd_set_bytes)) == NULL) if ((fd_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
goto fail_srevt; goto fail_srevt;
if ((StaticWriteEvent = (fd_set *)calloc(1, fd_set_bytes)) == NULL) if ((fd_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
goto fail_swevt; goto fail_swevt;
return 1; return 1;
fail_swevt: fail_swevt:
free(StaticReadEvent); free(fd_evts[DIR_RD]);
fail_srevt: fail_srevt:
free(poll_events); free(poll_events);
fail_pe: fail_pe:
@ -150,10 +120,10 @@ REGPRM1 static int poll_init(struct poller *p)
*/ */
REGPRM1 static void poll_term(struct poller *p) REGPRM1 static void poll_term(struct poller *p)
{ {
if (StaticWriteEvent) if (fd_evts[DIR_WR])
free(StaticWriteEvent); free(fd_evts[DIR_WR]);
if (StaticReadEvent) if (fd_evts[DIR_RD])
free(StaticReadEvent); free(fd_evts[DIR_RD]);
if (poll_events) if (poll_events)
free(poll_events); free(poll_events);
p->private = NULL; p->private = NULL;
@ -175,8 +145,8 @@ REGPRM2 static void poll_poll(struct poller *p, int wait_time)
nbfd = 0; nbfd = 0;
for (fds = 0; (fds << INTBITS) < maxfd; fds++) { for (fds = 0; (fds << INTBITS) < maxfd; fds++) {
rn = ((int*)StaticReadEvent)[fds]; rn = ((int*)fd_evts[DIR_RD])[fds];
wn = ((int*)StaticWriteEvent)[fds]; wn = ((int*)fd_evts[DIR_WR])[fds];
if ((rn|wn)) { if ((rn|wn)) {
for (count = 0, fd = fds << INTBITS; count < (1<<INTBITS) && fd < maxfd; count++, fd++) { for (count = 0, fd = fds << INTBITS; count < (1<<INTBITS) && fd < maxfd; count++, fd++) {
@ -192,8 +162,8 @@ REGPRM2 static void poll_poll(struct poller *p, int wait_time)
sw = FD_ISSET(fd&((1<<INTBITS)-1), (typeof(fd_set*))&wn); sw = FD_ISSET(fd&((1<<INTBITS)-1), (typeof(fd_set*))&wn);
#endif #endif
#else #else
sr = FD_ISSET(fd, StaticReadEvent); sr = FD_ISSET(fd, fd_evts[DIR_RD]);
sw = FD_ISSET(fd, StaticWriteEvent); sw = FD_ISSET(fd, fd_evts[DIR_WR]);
#endif #endif
if ((sr|sw)) { if ((sr|sw)) {
poll_events[nbfd].fd = fd; poll_events[nbfd].fd = fd;
@ -217,14 +187,14 @@ REGPRM2 static void poll_poll(struct poller *p, int wait_time)
/* ok, we found one active fd */ /* ok, we found one active fd */
status--; status--;
if (FD_ISSET(fd, StaticReadEvent)) { if (FD_ISSET(fd, fd_evts[DIR_RD])) {
if (fdtab[fd].state == FD_STCLOSE) if (fdtab[fd].state == FD_STCLOSE)
continue; continue;
if (poll_events[count].revents & ( POLLIN | POLLERR | POLLHUP )) if (poll_events[count].revents & ( POLLIN | POLLERR | POLLHUP ))
fdtab[fd].cb[DIR_RD].f(fd); fdtab[fd].cb[DIR_RD].f(fd);
} }
if (FD_ISSET(fd, StaticWriteEvent)) { if (FD_ISSET(fd, fd_evts[DIR_WR])) {
if (fdtab[fd].state == FD_STCLOSE) if (fdtab[fd].state == FD_STCLOSE)
continue; continue;
if (poll_events[count].revents & ( POLLOUT | POLLERR | POLLHUP )) if (poll_events[count].revents & ( POLLOUT | POLLERR | POLLHUP ))

View File

@ -26,8 +26,8 @@
#include <proto/task.h> #include <proto/task.h>
static fd_set *ReadEvent, *WriteEvent; static fd_set *fd_evts[2];
static fd_set *StaticReadEvent, *StaticWriteEvent; static fd_set *tmp_evts[2];
/* /*
@ -37,74 +37,45 @@ static fd_set *StaticReadEvent, *StaticWriteEvent;
*/ */
REGPRM2 static int __fd_isset(const int fd, const int dir) REGPRM2 static int __fd_isset(const int fd, const int dir)
{ {
fd_set *ev; return FD_ISSET(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
return FD_ISSET(fd, ev);
} }
REGPRM2 static void __fd_set(const int fd, const int dir) REGPRM2 static void __fd_set(const int fd, const int dir)
{ {
fd_set *ev; FD_SET(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
FD_SET(fd, ev);
} }
REGPRM2 static void __fd_clr(const int fd, const int dir) REGPRM2 static void __fd_clr(const int fd, const int dir)
{ {
fd_set *ev; FD_CLR(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
FD_CLR(fd, ev);
} }
REGPRM2 static int __fd_cond_s(const int fd, const int dir) REGPRM2 static int __fd_cond_s(const int fd, const int dir)
{ {
int ret; int ret;
fd_set *ev; ret = !FD_ISSET(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
ret = !FD_ISSET(fd, ev);
if (ret) if (ret)
FD_SET(fd, ev); FD_SET(fd, fd_evts[dir]);
return ret; return ret;
} }
REGPRM2 static int __fd_cond_c(const int fd, const int dir) REGPRM2 static int __fd_cond_c(const int fd, const int dir)
{ {
int ret; int ret;
fd_set *ev; ret = FD_ISSET(fd, fd_evts[dir]);
if (dir == DIR_RD)
ev = StaticReadEvent;
else
ev = StaticWriteEvent;
ret = FD_ISSET(fd, ev);
if (ret) if (ret)
FD_CLR(fd, ev); FD_CLR(fd, fd_evts[dir]);
return ret; return ret;
} }
REGPRM1 static void __fd_rem(const int fd) REGPRM1 static void __fd_rem(const int fd)
{ {
FD_CLR(fd, StaticReadEvent); FD_CLR(fd, fd_evts[DIR_RD]);
FD_CLR(fd, StaticWriteEvent); FD_CLR(fd, fd_evts[DIR_WR]);
} }
/* /*
* Initialization of the select() poller. * Initialization of the select() poller.
* Returns 0 in case of failure, non-zero in case of success. If it fails, it * Returns 0 in case of failure, non-zero in case of success. If it fails, it
@ -118,26 +89,26 @@ REGPRM1 static int select_init(struct poller *p)
p->private = NULL; p->private = NULL;
fd_set_bytes = sizeof(fd_set) * (global.maxsock + FD_SETSIZE - 1) / FD_SETSIZE; fd_set_bytes = sizeof(fd_set) * (global.maxsock + FD_SETSIZE - 1) / FD_SETSIZE;
if ((ReadEvent = (fd_set *)calloc(1, fd_set_bytes)) == NULL) if ((tmp_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
goto fail_revt; goto fail_revt;
if ((WriteEvent = (fd_set *)calloc(1, fd_set_bytes)) == NULL) if ((tmp_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
goto fail_wevt; goto fail_wevt;
if ((StaticReadEvent = (fd_set *)calloc(1, fd_set_bytes)) == NULL) if ((fd_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
goto fail_srevt; goto fail_srevt;
if ((StaticWriteEvent = (fd_set *)calloc(1, fd_set_bytes)) == NULL) if ((fd_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
goto fail_swevt; goto fail_swevt;
return 1; return 1;
fail_swevt: fail_swevt:
free(StaticReadEvent); free(fd_evts[DIR_RD]);
fail_srevt: fail_srevt:
free(WriteEvent); free(tmp_evts[DIR_WR]);
fail_wevt: fail_wevt:
free(ReadEvent); free(tmp_evts[DIR_RD]);
fail_revt: fail_revt:
p->pref = 0; p->pref = 0;
return 0; return 0;
@ -149,14 +120,14 @@ REGPRM1 static int select_init(struct poller *p)
*/ */
REGPRM1 static void select_term(struct poller *p) REGPRM1 static void select_term(struct poller *p)
{ {
if (StaticWriteEvent) if (fd_evts[DIR_WR])
free(StaticWriteEvent); free(fd_evts[DIR_WR]);
if (StaticReadEvent) if (fd_evts[DIR_RD])
free(StaticReadEvent); free(fd_evts[DIR_RD]);
if (WriteEvent) if (tmp_evts[DIR_WR])
free(WriteEvent); free(tmp_evts[DIR_WR]);
if (ReadEvent) if (tmp_evts[DIR_RD])
free(ReadEvent); free(tmp_evts[DIR_RD]);
p->private = NULL; p->private = NULL;
p->pref = 0; p->pref = 0;
} }
@ -187,22 +158,22 @@ REGPRM2 static void select_poll(struct poller *p, int wait_time)
readnotnull = 0; writenotnull = 0; readnotnull = 0; writenotnull = 0;
for (i = 0; i < (maxfd + FD_SETSIZE - 1)/(8*sizeof(int)); i++) { for (i = 0; i < (maxfd + FD_SETSIZE - 1)/(8*sizeof(int)); i++) {
readnotnull |= (*(((int*)ReadEvent)+i) = *(((int*)StaticReadEvent)+i)) != 0; readnotnull |= (*(((int*)tmp_evts[DIR_RD])+i) = *(((int*)fd_evts[DIR_RD])+i)) != 0;
writenotnull |= (*(((int*)WriteEvent)+i) = *(((int*)StaticWriteEvent)+i)) != 0; writenotnull |= (*(((int*)tmp_evts[DIR_WR])+i) = *(((int*)fd_evts[DIR_WR])+i)) != 0;
} }
// /* just a verification code, needs to be removed for performance */ // /* just a verification code, needs to be removed for performance */
// for (i=0; i<maxfd; i++) { // for (i=0; i<maxfd; i++) {
// if (FD_ISSET(i, ReadEvent) != FD_ISSET(i, StaticReadEvent)) // if (FD_ISSET(i, tmp_evts[DIR_RD]) != FD_ISSET(i, fd_evts[DIR_RD]))
// abort(); // abort();
// if (FD_ISSET(i, WriteEvent) != FD_ISSET(i, StaticWriteEvent)) // if (FD_ISSET(i, tmp_evts[DIR_WR]) != FD_ISSET(i, fd_evts[DIR_WR]))
// abort(); // abort();
// //
// } // }
status = select(maxfd, status = select(maxfd,
readnotnull ? ReadEvent : NULL, readnotnull ? tmp_evts[DIR_RD] : NULL,
writenotnull ? WriteEvent : NULL, writenotnull ? tmp_evts[DIR_WR] : NULL,
NULL, NULL,
(wait_time >= 0) ? &delta : NULL); (wait_time >= 0) ? &delta : NULL);
@ -212,20 +183,20 @@ REGPRM2 static void select_poll(struct poller *p, int wait_time)
return; return;
for (fds = 0; (fds << INTBITS) < maxfd; fds++) { for (fds = 0; (fds << INTBITS) < maxfd; fds++) {
if ((((int *)(ReadEvent))[fds] | ((int *)(WriteEvent))[fds]) == 0) if ((((int *)(tmp_evts[DIR_RD]))[fds] | ((int *)(tmp_evts[DIR_WR]))[fds]) == 0)
continue; continue;
for (count = 1<<INTBITS, fd = fds << INTBITS; count && fd < maxfd; count--, fd++) { for (count = 1<<INTBITS, fd = fds << INTBITS; count && fd < maxfd; count--, fd++) {
/* if we specify read first, the accepts and zero reads will be /* if we specify read first, the accepts and zero reads will be
* seen first. Moreover, system buffers will be flushed faster. * seen first. Moreover, system buffers will be flushed faster.
*/ */
if (FD_ISSET(fd, ReadEvent)) { if (FD_ISSET(fd, tmp_evts[DIR_RD])) {
if (fdtab[fd].state == FD_STCLOSE) if (fdtab[fd].state == FD_STCLOSE)
continue; continue;
fdtab[fd].cb[DIR_RD].f(fd); fdtab[fd].cb[DIR_RD].f(fd);
} }
if (FD_ISSET(fd, WriteEvent)) { if (FD_ISSET(fd, tmp_evts[DIR_WR])) {
if (fdtab[fd].state == FD_STCLOSE) if (fdtab[fd].state == FD_STCLOSE)
continue; continue;
fdtab[fd].cb[DIR_WR].f(fd); fdtab[fd].cb[DIR_WR].f(fd);