]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] http: rely on proxy->acl_requires to allocate hdr_idx
authorWilly Tarreau <w@1wt.eu>
Fri, 10 Jul 2009 21:52:51 +0000 (23:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Jul 2009 21:52:51 +0000 (23:52 +0200)
Right now only HTTP proxies may use HTTP headers in ACLs, but
when this evolves, we'll need to be able to allocate the hdr_idx
on demand. The solution consists in allocating it only when it is
certain that at least one ACL requires HTTP parsing, regardless
of the mode the proxy is in. This is what is achieved by this
patch.

src/client.c

index abf4d351a7222a0148e73d75964ac0cae750d5e3..cfd41e0e41061469fc66902b6e32002d4e68571f 100644 (file)
@@ -281,8 +281,13 @@ int event_accept(int fd) {
 
                                memset(txn->rsp.cap, 0, p->nb_rsp_cap*sizeof(char *));
                        }
+               }
 
-
+               if (p->acl_requires & ACL_USE_L7_ANY) {
+                       /* 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).
+                        */
                        txn->hdr_idx.size = MAX_HTTP_HDR;
 
                        if ((txn->hdr_idx.v = pool_alloc2(p->hdr_idx_pool)) == NULL)