]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM/MINOR: move the hdr_idx pools out of the proxy struct
authorWilly Tarreau <w@1wt.eu>
Mon, 24 Oct 2011 16:15:04 +0000 (18:15 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 24 Oct 2011 16:15:04 +0000 (18:15 +0200)
It makes no sense to have one pointer to the hdr_idx pool in each proxy
struct since these pools do not depend on the proxy. Let's have a common
pool instead as it is already the case for other types.

include/proto/hdr_idx.h
include/types/proxy.h
src/cfgparse.c
src/frontend.c
src/haproxy.c
src/hdr_idx.c
src/proxy.c
src/session.c

index 9e67a003a6d69da309c4652a15f96bffe1986dcb..3de4361178e97cbf26ecaa046ee2b1bc4e481611 100644 (file)
@@ -1,23 +1,23 @@
 /*
-  include/proto/hdr_idx.h
-  This file defines function prototypes for fast header indexation.
-
 Copyright (C) 2000-2006 Willy Tarreau - w@1wt.eu
-  
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation, version 2.1
-  exclusively.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
* include/proto/hdr_idx.h
* This file defines function prototypes for fast header indexation.
+ *
* Copyright (C) 2000-2011 Willy Tarreau - w@1wt.eu
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, version 2.1
* exclusively.
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
 #ifndef _PROTO_HDR_IDX_H
 #define _PROTO_HDR_IDX_H
@@ -25,6 +25,8 @@
 #include <common/config.h>
 #include <types/hdr_idx.h>
 
+extern struct pool_head *pool2_hdr_idx;
+
 /*
  * Initialize the list pointers.
  * list->size must already be set. If list->size is set and list->v is
index 46e03a166537aa2b4f3a5cf72d4d15ab1cc09933..2abd21331a903ff40e8cb6b709c12bc1cb6e2d57 100644 (file)
@@ -296,7 +296,6 @@ struct proxy {
        struct cap_hdr *rsp_cap;                /* chained list of response headers to be captured */
        struct pool_head *req_cap_pool,         /* pools of pre-allocated char ** used to build the sessions */
                         *rsp_cap_pool;
-       struct pool_head *hdr_idx_pool;         /* pools of pre-allocated int* used for headers indexing */
        struct list req_add, rsp_add;           /* headers to be added */
        struct pxcounters be_counters;          /* backend statistics counters */
        struct pxcounters fe_counters;          /* frontend statistics counters */
index ed64457625e925d75be3cf66cb052db61cdf436a..dac6bcab5ea31b5afb97e3bb4437d4a97840968e 100644 (file)
@@ -44,6 +44,7 @@
 #include <proto/checks.h>
 #include <proto/dumpstats.h>
 #include <proto/frontend.h>
+#include <proto/hdr_idx.h>
 #include <proto/lb_chash.h>
 #include <proto/lb_fwlc.h>
 #include <proto/lb_fwrr.h>
@@ -5991,10 +5992,6 @@ out_uri_auth_compat:
                                                             curproxy->nb_rsp_cap * sizeof(char *),
                                                             MEM_F_SHARED);
 
-               curproxy->hdr_idx_pool = create_pool("hdr_idx",
-                                                    MAX_HTTP_HDR * sizeof(struct hdr_idx_elem),
-                                                    MEM_F_SHARED);
-
                /* first, we will invert the servers list order */
                newsrv = NULL;
                while (curproxy->srv) {
@@ -6598,6 +6595,10 @@ out_uri_auth_compat:
                }
        }
 
+       pool2_hdr_idx = create_pool("hdr_idx",
+                                   MAX_HTTP_HDR * sizeof(struct hdr_idx_elem),
+                                   MEM_F_SHARED);
+
        if (cfgerr > 0)
                err_code |= ERR_ALERT | ERR_FATAL;
  out:
index 548cd025c61c3151f91c2996e4700f3daf68e2b7..195a42414d8246ad4d83cf043315de503aa8dfe1 100644 (file)
@@ -136,7 +136,7 @@ int frontend_accept(struct session *s)
                 */
                s->txn.hdr_idx.size = MAX_HTTP_HDR;
 
-               if (unlikely((s->txn.hdr_idx.v = pool_alloc2(s->fe->hdr_idx_pool)) == NULL))
+               if (unlikely((s->txn.hdr_idx.v = pool_alloc2(pool2_hdr_idx)) == NULL))
                        goto out_free_rspcap; /* no memory */
 
                /* and now initialize the HTTP transaction state */
index f54fc8eae680ca158e5cd233c22ac882319341b7..cd8df662e452445ed7f0998842cfe1bcf7cf32ae 100644 (file)
@@ -76,6 +76,7 @@
 #include <proto/buffers.h>
 #include <proto/checks.h>
 #include <proto/fd.h>
+#include <proto/hdr_idx.h>
 #include <proto/log.h>
 #include <proto/protocols.h>
 #include <proto/proto_http.h>
@@ -953,7 +954,6 @@ void deinit(void)
 
                pool_destroy2(p->req_cap_pool);
                pool_destroy2(p->rsp_cap_pool);
-               pool_destroy2(p->hdr_idx_pool);
                pool_destroy2(p->table.pool);
 
                p0 = p;
@@ -1003,6 +1003,7 @@ void deinit(void)
        pool_destroy2(pool2_appsess);
        pool_destroy2(pool2_pendconn);
        pool_destroy2(pool2_sig_handlers);
+       pool_destroy2(pool2_hdr_idx);
     
        if (have_appsession) {
                pool_destroy2(apools.serverid);
index a8c595d0e67e913fa2557a036bc00fe4e82b0782..13f9b55137b23afcf889454a80003afd1493c1f1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Header indexation functions.
  *
- * Copyright 2000-2008 Willy Tarreau <w@1wt.eu>
+ * Copyright 2000-2011 Willy Tarreau <w@1wt.eu>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  */
 
 #include <common/config.h>
+#include <common/memory.h>
 #include <proto/hdr_idx.h>
 
+struct pool_head *pool2_hdr_idx = NULL;
 
 /*
  * Add a header entry to <list> after element <after>. <after> is ignored when
index 14e37eb93f8b54c005e6ef32d2160256be683c32..d274dfe5fbfd1c51d6004c5ed4504b3a0e8f7fac 100644 (file)
@@ -813,7 +813,7 @@ int session_set_backend(struct session *s, struct proxy *be)
         * a struct hdr_idx for it if we did not have one.
         */
        if (unlikely(!s->txn.hdr_idx.v && (be->acl_requires & ACL_USE_L7_ANY))) {
-               if ((s->txn.hdr_idx.v = pool_alloc2(s->fe->hdr_idx_pool)) == NULL)
+               if ((s->txn.hdr_idx.v = pool_alloc2(pool2_hdr_idx)) == NULL)
                        return 0; /* not enough memory */
 
                /* and now initialize the HTTP transaction state */
index 9c66906032640926da67eb45dc6e902193e25652..dbef9ee6b7e066777730c3c6127eb765f87433da 100644 (file)
@@ -372,8 +372,8 @@ static void session_free(struct session *s)
                s->store[i].ts = NULL;
        }
 
+       pool_free2(pool2_hdr_idx, txn->hdr_idx.v);
        if (fe) {
-               pool_free2(fe->hdr_idx_pool, txn->hdr_idx.v);
                pool_free2(fe->rsp_cap_pool, txn->rsp.cap);
                pool_free2(fe->req_cap_pool, txn->req.cap);
        }
@@ -397,7 +397,7 @@ static void session_free(struct session *s)
        /* We may want to free the maximum amount of pools if the proxy is stopping */
        if (fe && unlikely(fe->state == PR_STSTOPPED)) {
                pool_flush2(pool2_buffer);
-               pool_flush2(fe->hdr_idx_pool);
+               pool_flush2(pool2_hdr_idx);
                pool_flush2(pool2_requri);
                pool_flush2(pool2_capture);
                pool_flush2(pool2_session);