[MINOR] add support for the polling results in fdtab
Now fdtab can contain the FD_POLL_* events so that the pollers
which can fill them can give userful information to readers and
writers about the precise condition of wakeup.
diff --git a/include/types/fd.h b/include/types/fd.h
index 37b5281..c97d8ed 100644
--- a/include/types/fd.h
+++ b/include/types/fd.h
@@ -43,14 +43,26 @@
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 0996925..2ae01db 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -336,6 +336,7 @@
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 46cf43e..521b860 100644
--- a/src/client.c
+++ b/src/client.c
@@ -385,6 +385,7 @@
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 93eab16..9096c91 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -153,6 +153,7 @@
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++;
}