]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: checks: make use of fdtab->iocb instead of cb[]
authorWilly Tarreau <wtarreau@exceliance.fr>
Fri, 6 Jul 2012 10:00:49 +0000 (12:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 2 Sep 2012 19:51:27 +0000 (21:51 +0200)
Use the single I/O callback to handle the checks. This should soon be
replaced by the common connection handler.

src/checks.c

index f24e1facd10fffe13fe4d7a1226533759bd3ab6d..d3861687d42377566ffc060d887cbaf10022beec 100644 (file)
@@ -1249,6 +1249,25 @@ static int event_srv_chk_r(int fd)
        return 0;
 }
 
+/* I/O call back for the health checks. Returns FD_WAIT_*. */
+static int check_iocb(int fd)
+{
+       int ret = 0;
+       int e;
+
+       if (!fdtab[fd].owner)
+               return ret;
+
+       e = fdtab[fd].ev;
+       if (e & (FD_POLL_IN | FD_POLL_HUP | FD_POLL_ERR))
+               if (!event_srv_chk_r(fd))
+                       ret |= FD_WAIT_READ;
+       if (e & (FD_POLL_OUT | FD_POLL_ERR))
+               if (!event_srv_chk_w(fd))
+                       ret |= FD_WAIT_WRITE;
+       return ret;
+}
+
 /*
  * updates the server's weight during a warmup stage. Once the final weight is
  * reached, the task automatically stops. Note that any server status change
@@ -1463,9 +1482,9 @@ static struct task *process_chk(struct task *t)
                                                s->check_conn->flags = CO_FL_WAIT_L4_CONN; /* TCP connection pending */
                                                fd_insert(fd);
                                                fdtab[fd].owner = t;
-                                               fdtab[fd].cb[DIR_RD].f = &event_srv_chk_r;
-                                               fdtab[fd].cb[DIR_WR].f = &event_srv_chk_w;
-                                               fdtab[fd].iocb = NULL;
+                                               fdtab[fd].cb[DIR_RD].f = NULL;
+                                               fdtab[fd].cb[DIR_WR].f = NULL;
+                                               fdtab[fd].iocb = &check_iocb;
                                                fdtab[fd].flags = FD_FL_TCP | FD_FL_TCP_NODELAY;
                                                EV_FD_SET(fd, DIR_WR);  /* for connect status */
 #ifdef DEBUG_FULL