]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] add support for the polling results in fdtab
authorWilly Tarreau <w@1wt.eu>
Sun, 15 Apr 2007 09:31:05 +0000 (11:31 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 15 Apr 2007 09:31:05 +0000 (11:31 +0200)
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.

include/types/fd.h
src/checks.c
src/client.c
src/proxy.c

index 37b5281ae78ecfc400b4686345b10cf1c66551b4..c97d8ed37c56667ebda8e3b640db6d367fcfa807 100644 (file)
@@ -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_* */
 };
 
 /*
index 099692579dc6bf5497b5b020c96d0a5459254a00..2ae01db56123ec965ebf3a4157ea75f2de836b9f 100644 (file)
@@ -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));
index 46cf43e4f81226008b6e9a007b742340a83d020e..521b8604b345b54284ebb74bcd3b763c6cca1665 100644 (file)
@@ -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))) {
index 93eab162cd13b7c69c37c7975c5861c9e26f7bf7..9096c91f2b662993878c7c44fcceb689f82fc309 100644 (file)
@@ -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++;
                }