]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] pre-set analyser flags on the listener at registration time
authorWilly Tarreau <w@1wt.eu>
Sun, 7 Dec 2008 10:50:35 +0000 (11:50 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 7 Dec 2008 10:50:35 +0000 (11:50 +0100)
In order to achieve more generic accept() code, we can set the request
analysers at the listener registration time. It's better than doing it
during accept(), and allows more code reuse.

include/types/protocols.h
src/cfgparse.c
src/client.c

index 0816351f6fee95c19d57253ac9d10a8111e01453..4c64551bb9fc4703f46b67613bddafa3eab146d3 100644 (file)
@@ -88,6 +88,7 @@ struct listener {
        void (*handler)(struct task *t, int *next); /* protocol handler */
        int  *timeout;                  /* pointer to client-side timeout */
        void *private;                  /* any private data which may be used by accept() */
+       unsigned int analysers;         /* bitmap of required protocol analysers */
        union {                         /* protocol-dependant access restrictions */
                struct {                /* UNIX socket permissions */
                        uid_t uid;      /* -1 to leave unchanged */
index 5f4e1238a3b18cf9166126ec2c4c9f1a94be9a3f..df297b6ab469df51eb3de37f1914a6ba5c63fe49 100644 (file)
@@ -46,6 +46,7 @@
 #include <proto/proto_http.h>
 #include <proto/proxy.h>
 #include <proto/server.h>
+#include <proto/session.h>
 #include <proto/task.h>
 
 
@@ -3218,6 +3219,13 @@ int readcfgfile(const char *file)
                        listener->timeout = &curproxy->timeout.client;
                        listener->accept = event_accept;
                        listener->private = curproxy;
+                       listener->handler = process_session;
+
+                       if (curproxy->mode == PR_MODE_HTTP)
+                               listener->analysers |= AN_REQ_HTTP_HDR;
+
+                       if (curproxy->tcp_req.inspect_delay)
+                               listener->analysers |= AN_REQ_INSPECT;
 
                        listener = listener->next;
                }
index bf7f55c7e8f717d77322f9b38bf8bab9f7ff7bf2..65ffdaae64f5d89c95c20b4e9f8b2fa9cf9e3784 100644 (file)
@@ -153,7 +153,7 @@ int event_accept(int fd) {
                        setsockopt(cfd, SOL_SOCKET, SO_LINGER, (struct linger *) &nolinger, sizeof(struct linger));
 
                task_init(t);
-               t->process = process_session;
+               t->process = l->handler;
                t->context = s;
 
                s->task = t;
@@ -366,11 +366,8 @@ int event_accept(int fd) {
                if (p->mode == PR_MODE_HTTP) /* reserve some space for header rewriting */
                        s->req->rlim -= MAXREWRITE;
 
-               if (s->fe->tcp_req.inspect_delay)
-                       s->req->analysers |= AN_REQ_INSPECT;
-
-               if (p->mode == PR_MODE_HTTP)
-                       s->req->analysers |= AN_REQ_HTTP_HDR;
+               /* activate default analysers enabled for this listener */
+               s->req->analysers = l->analysers;
 
                if (!s->req->analysers)
                        buffer_write_ena(s->req);  /* don't wait to establish connection */