mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-05-06 01:37:59 +00:00
MINOR: polling: Use fd_update_events to update events seen for a fd
Now, the same function is used by all pollers to update events seen for a fd. This will ease the threads support integration.
This commit is contained in:
parent
21e9267ac3
commit
ab62f51959
@ -139,7 +139,6 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
/* it looks complicated but gcc can optimize it away when constants
|
||||
* have same values... In fact it depends on gcc :-(
|
||||
*/
|
||||
fdtab[fd].ev &= FD_POLL_STICKY;
|
||||
if (EPOLLIN == FD_POLL_IN && EPOLLOUT == FD_POLL_OUT &&
|
||||
EPOLLPRI == FD_POLL_PRI && EPOLLERR == FD_POLL_ERR &&
|
||||
EPOLLHUP == FD_POLL_HUP) {
|
||||
@ -158,13 +157,7 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
cur_poller.flags |= HAP_POLL_F_RDHUP;
|
||||
n |= FD_POLL_HUP;
|
||||
}
|
||||
|
||||
fdtab[fd].ev |= n;
|
||||
if (fdtab[fd].ev & (FD_POLL_IN | FD_POLL_HUP | FD_POLL_ERR))
|
||||
fd_may_recv(fd);
|
||||
|
||||
if (fdtab[fd].ev & (FD_POLL_OUT | FD_POLL_ERR))
|
||||
fd_may_send(fd);
|
||||
fd_update_events(fd, n);
|
||||
}
|
||||
/* the caller will take care of cached events */
|
||||
}
|
||||
|
@ -117,30 +117,25 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
measure_idle();
|
||||
|
||||
for (count = 0; count < status; count++) {
|
||||
unsigned int n = 0;
|
||||
fd = kev[count].ident;
|
||||
|
||||
if (!fdtab[fd].owner)
|
||||
continue;
|
||||
|
||||
fdtab[fd].ev &= FD_POLL_STICKY;
|
||||
|
||||
if (kev[count].filter == EVFILT_READ) {
|
||||
if (kev[count].data)
|
||||
fdtab[fd].ev |= FD_POLL_IN;
|
||||
n |= FD_POLL_IN;
|
||||
if (kev[count].flags & EV_EOF)
|
||||
fdtab[fd].ev |= FD_POLL_HUP;
|
||||
n |= FD_POLL_HUP;
|
||||
}
|
||||
else if (kev[count].filter == EVFILT_WRITE) {
|
||||
fdtab[fd].ev |= FD_POLL_OUT;
|
||||
n |= FD_POLL_OUT;
|
||||
if (kev[count].flags & EV_EOF)
|
||||
fdtab[fd].ev |= FD_POLL_ERR;
|
||||
n |= FD_POLL_ERR;
|
||||
}
|
||||
|
||||
if (fdtab[fd].ev & (FD_POLL_IN | FD_POLL_HUP | FD_POLL_ERR))
|
||||
fd_may_recv(fd);
|
||||
|
||||
if (fdtab[fd].ev & (FD_POLL_OUT | FD_POLL_ERR))
|
||||
fd_may_send(fd);
|
||||
fd_update_events(fd, n);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,7 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
measure_idle();
|
||||
|
||||
for (count = 0; status > 0 && count < nbfd; count++) {
|
||||
unsigned int n;
|
||||
int e = poll_events[count].revents;
|
||||
fd = poll_events[count].fd;
|
||||
|
||||
@ -147,14 +148,12 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
/* it looks complicated but gcc can optimize it away when constants
|
||||
* have same values... In fact it depends on gcc :-(
|
||||
*/
|
||||
fdtab[fd].ev &= FD_POLL_STICKY;
|
||||
if (POLLIN == FD_POLL_IN && POLLOUT == FD_POLL_OUT &&
|
||||
POLLERR == FD_POLL_ERR && POLLHUP == FD_POLL_HUP) {
|
||||
fdtab[fd].ev |= e & (POLLIN|POLLOUT|POLLERR|POLLHUP);
|
||||
n = e & (POLLIN|POLLOUT|POLLERR|POLLHUP);
|
||||
}
|
||||
else {
|
||||
fdtab[fd].ev |=
|
||||
((e & POLLIN ) ? FD_POLL_IN : 0) |
|
||||
n = ((e & POLLIN ) ? FD_POLL_IN : 0) |
|
||||
((e & POLLOUT) ? FD_POLL_OUT : 0) |
|
||||
((e & POLLERR) ? FD_POLL_ERR : 0) |
|
||||
((e & POLLHUP) ? FD_POLL_HUP : 0);
|
||||
@ -163,14 +162,10 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
/* always remap RDHUP to HUP as they're used similarly */
|
||||
if (e & POLLRDHUP) {
|
||||
cur_poller.flags |= HAP_POLL_F_RDHUP;
|
||||
fdtab[fd].ev |= FD_POLL_HUP;
|
||||
n |= FD_POLL_HUP;
|
||||
}
|
||||
|
||||
if (fdtab[fd].ev & (FD_POLL_IN | FD_POLL_HUP | FD_POLL_ERR))
|
||||
fd_may_recv(fd);
|
||||
|
||||
if (fdtab[fd].ev & (FD_POLL_OUT | FD_POLL_ERR))
|
||||
fd_may_send(fd);
|
||||
fd_update_events(fd, n);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -129,24 +129,21 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
continue;
|
||||
|
||||
for (count = BITS_PER_INT, fd = fds * BITS_PER_INT; count && fd < maxfd; count--, fd++) {
|
||||
unsigned int n = 0;
|
||||
|
||||
/* if we specify read first, the accepts and zero reads will be
|
||||
* seen first. Moreover, system buffers will be flushed faster.
|
||||
*/
|
||||
if (!fdtab[fd].owner)
|
||||
continue;
|
||||
|
||||
fdtab[fd].ev &= FD_POLL_STICKY;
|
||||
if (FD_ISSET(fd, tmp_evts[DIR_RD]))
|
||||
fdtab[fd].ev |= FD_POLL_IN;
|
||||
n |= FD_POLL_IN;
|
||||
|
||||
if (FD_ISSET(fd, tmp_evts[DIR_WR]))
|
||||
fdtab[fd].ev |= FD_POLL_OUT;
|
||||
n |= FD_POLL_OUT;
|
||||
|
||||
if (fdtab[fd].ev & (FD_POLL_IN | FD_POLL_HUP | FD_POLL_ERR))
|
||||
fd_may_recv(fd);
|
||||
|
||||
if (fdtab[fd].ev & (FD_POLL_OUT | FD_POLL_ERR))
|
||||
fd_may_send(fd);
|
||||
fd_update_events(fd, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user