mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-18 19:50:54 +00:00
[MEDIUM] pollers: store the events in arrays
Instead of managing StaticReadEvent/StaticWriteEvent, use evts[dir]
This commit is contained in:
parent
663193882a
commit
28d86862bc
110
src/ev_epoll.c
110
src/ev_epoll.c
@ -34,8 +34,8 @@ _syscall4 (int, epoll_wait, int, epfd, struct epoll_event *, events, int, maxeve
|
||||
#endif
|
||||
|
||||
|
||||
static fd_set *StaticReadEvent, *StaticWriteEvent;
|
||||
static fd_set *PrevReadEvent, *PrevWriteEvent;
|
||||
static fd_set *fd_evts[2];
|
||||
static fd_set *old_evts[2];
|
||||
|
||||
/* private data */
|
||||
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)
|
||||
{
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
return FD_ISSET(fd, ev);
|
||||
return FD_ISSET(fd, fd_evts[dir]);
|
||||
}
|
||||
|
||||
REGPRM2 static void __fd_set(const int fd, const int dir)
|
||||
{
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
FD_SET(fd, ev);
|
||||
FD_SET(fd, fd_evts[dir]);
|
||||
}
|
||||
|
||||
REGPRM2 static void __fd_clr(const int fd, const int dir)
|
||||
{
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
FD_CLR(fd, ev);
|
||||
FD_CLR(fd, fd_evts[dir]);
|
||||
}
|
||||
|
||||
REGPRM2 static int __fd_cond_s(const int fd, const int dir)
|
||||
{
|
||||
int ret;
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
ret = !FD_ISSET(fd, ev);
|
||||
ret = !FD_ISSET(fd, fd_evts[dir]);
|
||||
if (ret)
|
||||
FD_SET(fd, ev);
|
||||
FD_SET(fd, fd_evts[dir]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
REGPRM2 static int __fd_cond_c(const int fd, const int dir)
|
||||
{
|
||||
int ret;
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
ret = FD_ISSET(fd, ev);
|
||||
ret = FD_ISSET(fd, fd_evts[dir]);
|
||||
if (ret)
|
||||
FD_CLR(fd, ev);
|
||||
FD_CLR(fd, fd_evts[dir]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
REGPRM1 static void __fd_rem(const int fd)
|
||||
{
|
||||
FD_CLR(fd, StaticReadEvent);
|
||||
FD_CLR(fd, StaticWriteEvent);
|
||||
FD_CLR(fd, fd_evts[DIR_RD]);
|
||||
FD_CLR(fd, fd_evts[DIR_WR]);
|
||||
}
|
||||
|
||||
REGPRM1 static void __fd_clo(const int fd)
|
||||
{
|
||||
FD_CLR(fd, StaticReadEvent);
|
||||
FD_CLR(fd, StaticWriteEvent);
|
||||
FD_CLR(fd, PrevReadEvent);
|
||||
FD_CLR(fd, PrevWriteEvent);
|
||||
FD_CLR(fd, fd_evts[DIR_RD]);
|
||||
FD_CLR(fd, fd_evts[DIR_WR]);
|
||||
FD_CLR(fd, old_evts[DIR_RD]);
|
||||
FD_CLR(fd, old_evts[DIR_WR]);
|
||||
}
|
||||
|
||||
|
||||
@ -149,26 +119,26 @@ REGPRM1 static int epoll_init(struct poller *p)
|
||||
if (epoll_events == NULL)
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
return 1;
|
||||
|
||||
fail_swevt:
|
||||
free(StaticReadEvent);
|
||||
free(fd_evts[DIR_RD]);
|
||||
fail_srevt:
|
||||
free(PrevWriteEvent);
|
||||
free(old_evts[DIR_WR]);
|
||||
fail_pwevt:
|
||||
free(PrevReadEvent);
|
||||
free(old_evts[DIR_RD]);
|
||||
fail_prevt:
|
||||
free(epoll_events);
|
||||
fail_ee:
|
||||
@ -185,17 +155,17 @@ REGPRM1 static int epoll_init(struct poller *p)
|
||||
*/
|
||||
REGPRM1 static void epoll_term(struct poller *p)
|
||||
{
|
||||
if (StaticWriteEvent)
|
||||
free(StaticWriteEvent);
|
||||
if (fd_evts[DIR_WR])
|
||||
free(fd_evts[DIR_WR]);
|
||||
|
||||
if (StaticReadEvent)
|
||||
free(StaticReadEvent);
|
||||
if (fd_evts[DIR_RD])
|
||||
free(fd_evts[DIR_RD]);
|
||||
|
||||
if (PrevWriteEvent)
|
||||
free(PrevWriteEvent);
|
||||
if (old_evts[DIR_WR])
|
||||
free(old_evts[DIR_WR]);
|
||||
|
||||
if (PrevReadEvent)
|
||||
free(PrevReadEvent);
|
||||
if (old_evts[DIR_RD])
|
||||
free(old_evts[DIR_RD]);
|
||||
|
||||
if (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++) {
|
||||
|
||||
rn = ((int*)StaticReadEvent)[fds]; ro = ((int*)PrevReadEvent)[fds];
|
||||
wn = ((int*)StaticWriteEvent)[fds]; wo = ((int*)PrevWriteEvent)[fds];
|
||||
rn = ((int*)fd_evts[DIR_RD])[fds]; ro = ((int*)old_evts[DIR_RD])[fds];
|
||||
wn = ((int*)fd_evts[DIR_WR])[fds]; wo = ((int*)old_evts[DIR_WR])[fds];
|
||||
|
||||
if ((ro^rn) | (wo^wn)) {
|
||||
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);
|
||||
#endif
|
||||
#else
|
||||
pr = FD_ISSET(fd, PrevReadEvent);
|
||||
pw = FD_ISSET(fd, PrevWriteEvent);
|
||||
sr = FD_ISSET(fd, StaticReadEvent);
|
||||
sw = FD_ISSET(fd, StaticWriteEvent);
|
||||
pr = FD_ISSET(fd, old_evts[DIR_RD]);
|
||||
pw = FD_ISSET(fd, old_evts[DIR_WR]);
|
||||
sr = FD_ISSET(fd, fd_evts[DIR_RD]);
|
||||
sw = FD_ISSET(fd, fd_evts[DIR_WR]);
|
||||
#endif
|
||||
if (!((sr^pr) | (sw^pw)))
|
||||
continue;
|
||||
@ -296,8 +266,8 @@ REGPRM2 static void epoll_poll(struct poller *p, int wait_time)
|
||||
}
|
||||
#endif // EPOLL_CTL_MOD_WORKAROUND
|
||||
}
|
||||
((int*)PrevReadEvent)[fds] = rn;
|
||||
((int*)PrevWriteEvent)[fds] = wn;
|
||||
((int*)old_evts[DIR_RD])[fds] = rn;
|
||||
((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++) {
|
||||
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)
|
||||
continue;
|
||||
if (epoll_events[count].events & ( EPOLLIN | EPOLLERR | EPOLLHUP ))
|
||||
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)
|
||||
continue;
|
||||
if (epoll_events[count].events & ( EPOLLOUT | EPOLLERR | EPOLLHUP ))
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <proto/task.h>
|
||||
|
||||
|
||||
static fd_set *StaticReadEvent, *StaticWriteEvent;
|
||||
static fd_set *fd_evts[2];
|
||||
|
||||
/* private data */
|
||||
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)
|
||||
{
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
return FD_ISSET(fd, ev);
|
||||
return FD_ISSET(fd, fd_evts[dir]);
|
||||
}
|
||||
|
||||
REGPRM2 static void __fd_set(const int fd, const int dir)
|
||||
{
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
FD_SET(fd, ev);
|
||||
FD_SET(fd, fd_evts[dir]);
|
||||
}
|
||||
|
||||
REGPRM2 static void __fd_clr(const int fd, const int dir)
|
||||
{
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
FD_CLR(fd, ev);
|
||||
FD_CLR(fd, fd_evts[dir]);
|
||||
}
|
||||
|
||||
REGPRM2 static int __fd_cond_s(const int fd, const int dir)
|
||||
{
|
||||
int ret;
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
ret = !FD_ISSET(fd, ev);
|
||||
ret = !FD_ISSET(fd, fd_evts[dir]);
|
||||
if (ret)
|
||||
FD_SET(fd, ev);
|
||||
FD_SET(fd, fd_evts[dir]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
REGPRM2 static int __fd_cond_c(const int fd, const int dir)
|
||||
{
|
||||
int ret;
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
ret = FD_ISSET(fd, ev);
|
||||
ret = FD_ISSET(fd, fd_evts[dir]);
|
||||
if (ret)
|
||||
FD_CLR(fd, ev);
|
||||
FD_CLR(fd, fd_evts[dir]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
REGPRM1 static void __fd_rem(const int fd)
|
||||
{
|
||||
FD_CLR(fd, StaticReadEvent);
|
||||
FD_CLR(fd, StaticWriteEvent);
|
||||
FD_CLR(fd, fd_evts[DIR_RD]);
|
||||
FD_CLR(fd, fd_evts[DIR_WR]);
|
||||
}
|
||||
|
||||
|
||||
@ -127,16 +97,16 @@ REGPRM1 static int poll_init(struct poller *p)
|
||||
if (poll_events == NULL)
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
return 1;
|
||||
|
||||
fail_swevt:
|
||||
free(StaticReadEvent);
|
||||
free(fd_evts[DIR_RD]);
|
||||
fail_srevt:
|
||||
free(poll_events);
|
||||
fail_pe:
|
||||
@ -150,10 +120,10 @@ REGPRM1 static int poll_init(struct poller *p)
|
||||
*/
|
||||
REGPRM1 static void poll_term(struct poller *p)
|
||||
{
|
||||
if (StaticWriteEvent)
|
||||
free(StaticWriteEvent);
|
||||
if (StaticReadEvent)
|
||||
free(StaticReadEvent);
|
||||
if (fd_evts[DIR_WR])
|
||||
free(fd_evts[DIR_WR]);
|
||||
if (fd_evts[DIR_RD])
|
||||
free(fd_evts[DIR_RD]);
|
||||
if (poll_events)
|
||||
free(poll_events);
|
||||
p->private = NULL;
|
||||
@ -175,8 +145,8 @@ REGPRM2 static void poll_poll(struct poller *p, int wait_time)
|
||||
nbfd = 0;
|
||||
for (fds = 0; (fds << INTBITS) < maxfd; fds++) {
|
||||
|
||||
rn = ((int*)StaticReadEvent)[fds];
|
||||
wn = ((int*)StaticWriteEvent)[fds];
|
||||
rn = ((int*)fd_evts[DIR_RD])[fds];
|
||||
wn = ((int*)fd_evts[DIR_WR])[fds];
|
||||
|
||||
if ((rn|wn)) {
|
||||
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);
|
||||
#endif
|
||||
#else
|
||||
sr = FD_ISSET(fd, StaticReadEvent);
|
||||
sw = FD_ISSET(fd, StaticWriteEvent);
|
||||
sr = FD_ISSET(fd, fd_evts[DIR_RD]);
|
||||
sw = FD_ISSET(fd, fd_evts[DIR_WR]);
|
||||
#endif
|
||||
if ((sr|sw)) {
|
||||
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 */
|
||||
status--;
|
||||
|
||||
if (FD_ISSET(fd, StaticReadEvent)) {
|
||||
if (FD_ISSET(fd, fd_evts[DIR_RD])) {
|
||||
if (fdtab[fd].state == FD_STCLOSE)
|
||||
continue;
|
||||
if (poll_events[count].revents & ( POLLIN | POLLERR | POLLHUP ))
|
||||
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)
|
||||
continue;
|
||||
if (poll_events[count].revents & ( POLLOUT | POLLERR | POLLHUP ))
|
||||
|
101
src/ev_select.c
101
src/ev_select.c
@ -26,8 +26,8 @@
|
||||
#include <proto/task.h>
|
||||
|
||||
|
||||
static fd_set *ReadEvent, *WriteEvent;
|
||||
static fd_set *StaticReadEvent, *StaticWriteEvent;
|
||||
static fd_set *fd_evts[2];
|
||||
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)
|
||||
{
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
return FD_ISSET(fd, ev);
|
||||
return FD_ISSET(fd, fd_evts[dir]);
|
||||
}
|
||||
|
||||
REGPRM2 static void __fd_set(const int fd, const int dir)
|
||||
{
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
FD_SET(fd, ev);
|
||||
FD_SET(fd, fd_evts[dir]);
|
||||
}
|
||||
|
||||
REGPRM2 static void __fd_clr(const int fd, const int dir)
|
||||
{
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
FD_CLR(fd, ev);
|
||||
FD_CLR(fd, fd_evts[dir]);
|
||||
}
|
||||
|
||||
REGPRM2 static int __fd_cond_s(const int fd, const int dir)
|
||||
{
|
||||
int ret;
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
ret = !FD_ISSET(fd, ev);
|
||||
ret = !FD_ISSET(fd, fd_evts[dir]);
|
||||
if (ret)
|
||||
FD_SET(fd, ev);
|
||||
FD_SET(fd, fd_evts[dir]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
REGPRM2 static int __fd_cond_c(const int fd, const int dir)
|
||||
{
|
||||
int ret;
|
||||
fd_set *ev;
|
||||
if (dir == DIR_RD)
|
||||
ev = StaticReadEvent;
|
||||
else
|
||||
ev = StaticWriteEvent;
|
||||
|
||||
ret = FD_ISSET(fd, ev);
|
||||
ret = FD_ISSET(fd, fd_evts[dir]);
|
||||
if (ret)
|
||||
FD_CLR(fd, ev);
|
||||
FD_CLR(fd, fd_evts[dir]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
REGPRM1 static void __fd_rem(const int fd)
|
||||
{
|
||||
FD_CLR(fd, StaticReadEvent);
|
||||
FD_CLR(fd, StaticWriteEvent);
|
||||
FD_CLR(fd, fd_evts[DIR_RD]);
|
||||
FD_CLR(fd, fd_evts[DIR_WR]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Initialization of the select() poller.
|
||||
* 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;
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
return 1;
|
||||
|
||||
fail_swevt:
|
||||
free(StaticReadEvent);
|
||||
free(fd_evts[DIR_RD]);
|
||||
fail_srevt:
|
||||
free(WriteEvent);
|
||||
free(tmp_evts[DIR_WR]);
|
||||
fail_wevt:
|
||||
free(ReadEvent);
|
||||
free(tmp_evts[DIR_RD]);
|
||||
fail_revt:
|
||||
p->pref = 0;
|
||||
return 0;
|
||||
@ -149,14 +120,14 @@ REGPRM1 static int select_init(struct poller *p)
|
||||
*/
|
||||
REGPRM1 static void select_term(struct poller *p)
|
||||
{
|
||||
if (StaticWriteEvent)
|
||||
free(StaticWriteEvent);
|
||||
if (StaticReadEvent)
|
||||
free(StaticReadEvent);
|
||||
if (WriteEvent)
|
||||
free(WriteEvent);
|
||||
if (ReadEvent)
|
||||
free(ReadEvent);
|
||||
if (fd_evts[DIR_WR])
|
||||
free(fd_evts[DIR_WR]);
|
||||
if (fd_evts[DIR_RD])
|
||||
free(fd_evts[DIR_RD]);
|
||||
if (tmp_evts[DIR_WR])
|
||||
free(tmp_evts[DIR_WR]);
|
||||
if (tmp_evts[DIR_RD])
|
||||
free(tmp_evts[DIR_RD]);
|
||||
p->private = NULL;
|
||||
p->pref = 0;
|
||||
}
|
||||
@ -187,22 +158,22 @@ REGPRM2 static void select_poll(struct poller *p, int wait_time)
|
||||
|
||||
readnotnull = 0; writenotnull = 0;
|
||||
for (i = 0; i < (maxfd + FD_SETSIZE - 1)/(8*sizeof(int)); i++) {
|
||||
readnotnull |= (*(((int*)ReadEvent)+i) = *(((int*)StaticReadEvent)+i)) != 0;
|
||||
writenotnull |= (*(((int*)WriteEvent)+i) = *(((int*)StaticWriteEvent)+i)) != 0;
|
||||
readnotnull |= (*(((int*)tmp_evts[DIR_RD])+i) = *(((int*)fd_evts[DIR_RD])+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 */
|
||||
// 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();
|
||||
// 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();
|
||||
//
|
||||
// }
|
||||
|
||||
status = select(maxfd,
|
||||
readnotnull ? ReadEvent : NULL,
|
||||
writenotnull ? WriteEvent : NULL,
|
||||
readnotnull ? tmp_evts[DIR_RD] : NULL,
|
||||
writenotnull ? tmp_evts[DIR_WR] : NULL,
|
||||
NULL,
|
||||
(wait_time >= 0) ? &delta : NULL);
|
||||
|
||||
@ -212,20 +183,20 @@ REGPRM2 static void select_poll(struct poller *p, int wait_time)
|
||||
return;
|
||||
|
||||
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;
|
||||
|
||||
for (count = 1<<INTBITS, fd = fds << INTBITS; count && fd < maxfd; count--, fd++) {
|
||||
/* if we specify read first, the accepts and zero reads will be
|
||||
* 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)
|
||||
continue;
|
||||
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)
|
||||
continue;
|
||||
fdtab[fd].cb[DIR_WR].f(fd);
|
||||
|
Loading…
Reference in New Issue
Block a user