]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: frontend: initialize HTTP layer after the debugging code
authorWilly Tarreau <w@1wt.eu>
Sun, 4 Dec 2016 17:39:22 +0000 (18:39 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 27 Jun 2017 12:38:02 +0000 (14:38 +0200)
For HTTP/2 we'll have to choose the upper layer based on the
advertised protocol name here and we want to keep debugging,
so let's move debugging earlier.

src/frontend.c

index 2fafdeaf7c1593fa42f140e6ff75141511cbd9bd..4ad3cfe58b8ad592e49457c928badd9fecfa317a 100644 (file)
@@ -57,30 +57,6 @@ int frontend_accept(struct stream *s)
        struct listener *l = sess->listener;
        struct proxy *fe = sess->fe;
 
-       if (unlikely(fe->nb_req_cap > 0)) {
-               if ((s->req_cap = pool_alloc2(fe->req_cap_pool)) == NULL)
-                       goto out_return;        /* no memory */
-               memset(s->req_cap, 0, fe->nb_req_cap * sizeof(void *));
-       }
-
-       if (unlikely(fe->nb_rsp_cap > 0)) {
-               if ((s->res_cap = pool_alloc2(fe->rsp_cap_pool)) == NULL)
-                       goto out_free_reqcap;   /* no memory */
-               memset(s->res_cap, 0, fe->nb_rsp_cap * sizeof(void *));
-       }
-
-       if (fe->http_needed) {
-               /* we have to allocate header indexes only if we know
-                * that we may make use of them. This of course includes
-                * (mode == PR_MODE_HTTP).
-                */
-               if (unlikely(!http_alloc_txn(s)))
-                       goto out_free_rspcap; /* no memory */
-
-               /* and now initialize the HTTP transaction state */
-               http_init_txn(s);
-       }
-
        if ((fe->mode == PR_MODE_TCP || fe->mode == PR_MODE_HTTP)
            && (!LIST_ISEMPTY(&fe->logsrvs))) {
                if (likely(!LIST_ISEMPTY(&fe->logformat))) {
@@ -141,6 +117,30 @@ int frontend_accept(struct stream *s)
        if (fe->mode == PR_MODE_HTTP)
                s->req.flags |= CF_READ_DONTWAIT; /* one read is usually enough */
 
+       if (unlikely(fe->nb_req_cap > 0)) {
+               if ((s->req_cap = pool_alloc2(fe->req_cap_pool)) == NULL)
+                       goto out_return;        /* no memory */
+               memset(s->req_cap, 0, fe->nb_req_cap * sizeof(void *));
+       }
+
+       if (unlikely(fe->nb_rsp_cap > 0)) {
+               if ((s->res_cap = pool_alloc2(fe->rsp_cap_pool)) == NULL)
+                       goto out_free_reqcap;   /* no memory */
+               memset(s->res_cap, 0, fe->nb_rsp_cap * sizeof(void *));
+       }
+
+       if (fe->http_needed) {
+               /* we have to allocate header indexes only if we know
+                * that we may make use of them. This of course includes
+                * (mode == PR_MODE_HTTP).
+                */
+               if (unlikely(!http_alloc_txn(s)))
+                       goto out_free_rspcap; /* no memory */
+
+               /* and now initialize the HTTP transaction state */
+               http_init_txn(s);
+       }
+
        /* everything's OK, let's go on */
        return 1;