diff --git a/include/types/fd.h b/include/types/fd.h index 37b5281ae..c97d8ed37 100644 --- a/include/types/fd.h +++ b/include/types/fd.h @@ -43,14 +43,26 @@ enum { DIR_SIZE }; + +#define FD_POLL_IN 0x01 +#define FD_POLL_PRI 0x02 +#define FD_POLL_OUT 0x04 +#define FD_POLL_ERR 0x08 +#define FD_POLL_HUP 0x10 +#define FD_POLL_ANY 0x1F + +#define FD_POLL_RD (FD_POLL_IN | FD_POLL_ERR | FD_POLL_HUP) +#define FD_POLL_WR (FD_POLL_OUT | FD_POLL_ERR | FD_POLL_HUP) + /* info about one given fd */ struct fdtab { struct { int (*f)(int fd); /* read/write function */ struct buffer *b; /* read/write buffer */ } cb[DIR_SIZE]; - struct task *owner; /* the session (or proxy) associated with this fd */ - int state; /* the state of this fd */ + struct task *owner; /* the session (or proxy) associated with this fd */ + unsigned char state; /* the state of this fd */ + unsigned char ev; /* event seen in return of poll() : FD_POLL_* */ }; /* diff --git a/src/checks.c b/src/checks.c index 099692579..2ae01db56 100644 --- a/src/checks.c +++ b/src/checks.c @@ -336,6 +336,7 @@ int process_chk(struct task *t) fdtab[fd].cb[DIR_WR].f = &event_srv_chk_w; fdtab[fd].cb[DIR_WR].b = NULL; fdtab[fd].state = FD_STCONN; /* connection in progress */ + fdtab[fd].ev = 0; EV_FD_SET(fd, DIR_WR); /* for connect status */ #ifdef DEBUG_FULL assert (!EV_FD_ISSET(fd, DIR_RD)); diff --git a/src/client.c b/src/client.c index 46cf43e4f..521b8604b 100644 --- a/src/client.c +++ b/src/client.c @@ -385,6 +385,7 @@ int event_accept(int fd) { fdtab[cfd].cb[DIR_RD].b = s->req; fdtab[cfd].cb[DIR_WR].f = &stream_sock_write; fdtab[cfd].cb[DIR_WR].b = s->rep; + fdtab[cfd].ev = 0; if ((p->mode == PR_MODE_HTTP && (s->flags & SN_MONITOR)) || (p->mode == PR_MODE_HEALTH && (p->options & PR_O_HTTP_CHK))) { diff --git a/src/proxy.c b/src/proxy.c index 93eab162c..9096c91f2 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -153,6 +153,7 @@ int start_proxies(int verbose) fdtab[fd].cb[DIR_RD].b = fdtab[fd].cb[DIR_WR].b = NULL; fdtab[fd].owner = (struct task *)curproxy; /* reference the proxy instead of a task */ fdtab[fd].state = FD_STLISTEN; + fdtab[fd].ev = 0; listeners++; }