From 8bb46f4015240a8f17a777542c48520740b7601f Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 30 Apr 2007 12:56:21 +0200 Subject: [PATCH] [MINOR] ev_sepoll: refine flags management. Ensure that we don't call the event handlers if the FD is already marked FD_STERROR, and ensure that we properly catch HUP and ERR. --- src/ev_sepoll.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ev_sepoll.c b/src/ev_sepoll.c index 24a343e38..74917add8 100644 --- a/src/ev_sepoll.c +++ b/src/ev_sepoll.c @@ -295,7 +295,7 @@ REGPRM2 static void _do_poll(struct poller *p, int wait_time) fdtab[fd].ev = 0; if ((fd_list[fd].e & FD_EV_MASK_R) == FD_EV_SPEC_R) { - if (fdtab[fd].state != FD_STCLOSE) { + if (fdtab[fd].state != FD_STCLOSE && fdtab[fd].state != FD_STERROR) { fdtab[fd].ev |= FD_POLL_IN; if (fdtab[fd].cb[DIR_RD].f(fd) == 0) status |= EPOLLIN; @@ -303,7 +303,7 @@ REGPRM2 static void _do_poll(struct poller *p, int wait_time) } if ((fd_list[fd].e & FD_EV_MASK_W) == FD_EV_SPEC_W) { - if (fdtab[fd].state != FD_STCLOSE) { + if (fdtab[fd].state != FD_STCLOSE && fdtab[fd].state != FD_STERROR) { fdtab[fd].ev |= FD_POLL_OUT; if (fdtab[fd].cb[DIR_WR].f(fd) == 0) status |= EPOLLOUT; @@ -383,16 +383,16 @@ REGPRM2 static void _do_poll(struct poller *p, int wait_time) ((e & EPOLLHUP) ? FD_POLL_HUP : 0); if ((fd_list[fd].e & FD_EV_MASK_R) == FD_EV_WAIT_R) { - if (fdtab[fd].state == FD_STCLOSE) + if (fdtab[fd].state == FD_STCLOSE || fdtab[fd].state == FD_STERROR) continue; - if (fdtab[fd].ev & FD_POLL_RD) + if (fdtab[fd].ev & (FD_POLL_RD|FD_POLL_HUP|FD_POLL_ERR)) fdtab[fd].cb[DIR_RD].f(fd); } if ((fd_list[fd].e & FD_EV_MASK_W) == FD_EV_WAIT_W) { - if (fdtab[fd].state == FD_STCLOSE) + if (fdtab[fd].state == FD_STCLOSE || fdtab[fd].state == FD_STERROR) continue; - if (fdtab[fd].ev & FD_POLL_WR) + if (fdtab[fd].ev & (FD_POLL_WR|FD_POLL_ERR)) fdtab[fd].cb[DIR_WR].f(fd); } }