From: Willy Tarreau Date: Sun, 4 Dec 2016 17:39:22 +0000 (+0100) Subject: MINOR: frontend: initialize HTTP layer after the debugging code X-Git-Tag: v1.8-dev3~269 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0a6bed2394dabf7f05a7a2af2fc9b8ba936073be;p=thirdparty%2Fhaproxy.git MINOR: frontend: initialize HTTP layer after the debugging code 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. --- diff --git a/src/frontend.c b/src/frontend.c index 2fafdeaf7c..4ad3cfe58b 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -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;