From: Willy Tarreau Date: Fri, 6 Jul 2012 08:53:51 +0000 (+0200) Subject: MINOR: fd: add a new I/O handler to fdtab X-Git-Tag: v1.5-dev12~118 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e6049e55360e642fceba7829b59f3a262b2df9a;p=thirdparty%2Fhaproxy.git MINOR: fd: add a new I/O handler to fdtab This one will eventually replace both cb[] handlers. At the moment it is not used yet. --- diff --git a/include/types/fd.h b/include/types/fd.h index 3b009942c1..c4133a92dd 100644 --- a/include/types/fd.h +++ b/include/types/fd.h @@ -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]; diff --git a/src/checks.c b/src/checks.c index 2c2ee7ef7f..f24e1facd1 100644 --- a/src/checks.c +++ b/src/checks.c @@ -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 diff --git a/src/proto_tcp.c b/src/proto_tcp.c index ddc8269e06..41a31b8831 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -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: diff --git a/src/proto_uxst.c b/src/proto_uxst.c index f63760183f..2dc5613e95 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -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: diff --git a/src/session.c b/src/session.c index c67d85ec38..0b0c3dacbe 100644 --- a/src/session.c +++ b/src/session.c @@ -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) {