]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: fd: add a new I/O handler to fdtab
authorWilly Tarreau <wtarreau@exceliance.fr>
Fri, 6 Jul 2012 08:53:51 +0000 (10:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 2 Sep 2012 19:51:27 +0000 (21:51 +0200)
This one will eventually replace both cb[] handlers. At the moment it
is not used yet.

include/types/fd.h
src/checks.c
src/proto_tcp.c
src/proto_uxst.c
src/session.c

index 3b009942c182de5847e88290125f08ecdf996d2f..c4133a92dd0d11856b565ca7bb10fe738d86f20f 100644 (file)
@@ -51,6 +51,11 @@ enum {
 #define FD_POLL_DATA    (FD_POLL_IN  | FD_POLL_OUT)
 #define FD_POLL_STICKY  (FD_POLL_ERR | FD_POLL_HUP)
 
+/* flags that an I/O callback may return */
+#define FD_WAIT_READ    0x01
+#define FD_WAIT_WRITE   0x02
+#define FD_WAIT_BOTH    (FD_WAIT_READ|FD_WAIT_WRITE)
+
 /* bit values for fdtab[fd]->flags. Most of them are used to hold a value
  * consecutive to a behaviour change.
  */
@@ -60,6 +65,7 @@ enum {
 
 /* info about one given fd */
 struct fdtab {
+       int (*iocb)(int fd);                 /* I/O handler, returns FD_WAIT_* */
        struct {
                int (*f)(int fd);            /* read/write function */
        } cb[DIR_SIZE];
index 2c2ee7ef7f0fc7b52a62d0bc896e6e23512e41d0..f24e1facd10fffe13fe4d7a1226533759bd3ab6d 100644 (file)
@@ -1465,6 +1465,7 @@ static struct task *process_chk(struct task *t)
                                                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].flags = FD_FL_TCP | FD_FL_TCP_NODELAY;
                                                EV_FD_SET(fd, DIR_WR);  /* for connect status */
 #ifdef DEBUG_FULL
index ddc8269e06f0b0acd5eb51e7e17f581470272b24..41a31b8831847bfec6402b7949ff86574b91c3e4 100644 (file)
@@ -476,10 +476,12 @@ int tcp_connect_server(struct stream_interface *si)
        if ((si->ob->flags & BF_OUT_EMPTY) || si->send_proxy_ofs) {
                fdtab[fd].cb[DIR_RD].f = tcp_connect_read;
                fdtab[fd].cb[DIR_WR].f = tcp_connect_write;
+               fdtab[fd].iocb = NULL;
        }
        else {
                fdtab[fd].cb[DIR_RD].f = si_data(si)->read;
                fdtab[fd].cb[DIR_WR].f = si_data(si)->write;
+               fdtab[fd].iocb = NULL;
        }
 
        fd_insert(fd);
@@ -821,6 +823,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
        fdtab[fd].flags = FD_FL_TCP | ((listener->options & LI_O_NOLINGER) ? FD_FL_TCP_NOLING : 0);
        fdtab[fd].cb[DIR_RD].f = listener->proto->accept;
        fdtab[fd].cb[DIR_WR].f = NULL; /* never called */
+       fdtab[fd].iocb = NULL;
        fd_insert(fd);
 
  tcp_return:
index f63760183f8605a63e03d5096fad25d9a065842f..2dc5613e95947e62b560786c7a216bbc0835bd64 100644 (file)
@@ -264,6 +264,7 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
        fd_insert(fd);
        fdtab[fd].cb[DIR_RD].f = listener->proto->accept;
        fdtab[fd].cb[DIR_WR].f = NULL; /* never called */
+       fdtab[fd].iocb = NULL;
        fdtab[fd].owner = listener; /* reference the listener instead of a task */
        return ERR_NONE;
  err_rename:
index c67d85ec38fdb018dd52bd620eaf545c9bd754bd..0b0c3dacbebeb281f479ff07f9a0c1800e78f25d 100644 (file)
@@ -284,6 +284,7 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
        fdtab[cfd].flags = 0;
        fdtab[cfd].cb[DIR_RD].f = si_data(&s->si[0])->read;
        fdtab[cfd].cb[DIR_WR].f = si_data(&s->si[0])->write;
+       fdtab[cfd].iocb = NULL;
        EV_FD_SET(cfd, DIR_RD);
 
        if (p->accept && (ret = p->accept(s)) <= 0) {