]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MAJOR] convert the header indexes to use mempool v2
authorWilly Tarreau <w@1wt.eu>
Sun, 13 May 2007 20:57:02 +0000 (22:57 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 13 May 2007 20:57:02 +0000 (22:57 +0200)
include/types/proxy.h
src/cfgparse.c
src/client.c
src/session.c

index 9be81d59e86387287235c506ebd8a1cbc21cab65..bfbe631251634d422484e8b27b499a3d18bf311e 100644 (file)
@@ -142,7 +142,7 @@ 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;
-       void *hdr_idx_pool;                     /* pools of pre-allocated int* used for headers indexing */
+       struct pool_head *hdr_idx_pool;         /* pools of pre-allocated int* used for headers indexing */
        char *req_add[MAX_NEWHDR], *rsp_add[MAX_NEWHDR]; /* headers to be added */
        int grace;                              /* grace time after stop request */
        char *check_req;                        /* HTTP or SSL request to use for PR_O_HTTP_CHK|PR_O_SSL3_CHK */
index b532ce92d00db5e7a73736b2ac9c4cabb9637e30..516547445264773e939a0e0309d3cbdb77e91c3b 100644 (file)
@@ -2413,6 +2413,10 @@ int readcfgfile(const char *file)
                                                             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);
+
                /* for backwards compatibility with "listen" instances, if
                 * fullconn is not set but maxconn is set, then maxconn
                 * is used.
index 38815e7712986b10ed1ed88cc0e1c2eaac535864..50a0f5d2fb2e9ce080b3b4d41f4b8ff5480803b4 100644 (file)
@@ -230,8 +230,6 @@ int event_accept(int fd) {
                        txn->req.som = txn->req.eoh = 0; /* relative to the buffer */
                        txn->auth_hdr.len = -1;
 
-                       txn->hdr_idx.size = MAX_HTTP_HDR;
-
                        if (p->nb_req_cap > 0) {
                                if ((txn->req.cap = pool_alloc2(p->req_cap_pool)) == NULL) {
                                        /* no memory */
@@ -258,9 +256,10 @@ int event_accept(int fd) {
                        }
 
 
-                       if ((txn->hdr_idx.v =
-                            pool_alloc_from(p->hdr_idx_pool, txn->hdr_idx.size*sizeof(*txn->hdr_idx.v)))
-                           == NULL) { /* no memory */
+                       txn->hdr_idx.size = MAX_HTTP_HDR;
+
+                       if ((txn->hdr_idx.v = pool_alloc2(p->hdr_idx_pool)) == NULL) {
+                               /* no memory */
                                if (txn->rsp.cap != NULL)
                                        pool_free2(p->rsp_cap_pool, txn->rsp.cap);
                                if (txn->req.cap != NULL)
@@ -347,7 +346,7 @@ int event_accept(int fd) {
 
                if ((s->req = pool_alloc2(pool2_buffer)) == NULL) { /* no memory */
                        if (txn->hdr_idx.v != NULL)
-                               pool_free_to(p->hdr_idx_pool, txn->hdr_idx.v);
+                               pool_free2(p->hdr_idx_pool, txn->hdr_idx.v);
                        if (txn->rsp.cap != NULL)
                                pool_free2(p->rsp_cap_pool, txn->rsp.cap);
                        if (txn->req.cap != NULL)
@@ -370,7 +369,7 @@ int event_accept(int fd) {
                if ((s->rep = pool_alloc2(pool2_buffer)) == NULL) { /* no memory */
                        pool_free2(pool2_buffer, s->req);
                        if (txn->hdr_idx.v != NULL)
-                               pool_free_to(p->hdr_idx_pool, txn->hdr_idx.v);
+                               pool_free2(p->hdr_idx_pool, txn->hdr_idx.v);
                        if (txn->rsp.cap != NULL)
                                pool_free2(p->rsp_cap_pool, txn->rsp.cap);
                        if (txn->req.cap != NULL)
index 01073de62117bc572066027bbabc09e9ade6ea15..d13f99504e2fec9ed6b07714b70bd62b086b2ed8 100644 (file)
@@ -45,7 +45,7 @@ void session_free(struct session *s)
                pool_free2(pool2_buffer, s->rep);
 
        if (txn->hdr_idx.v != NULL)
-               pool_free_to(s->fe->hdr_idx_pool, txn->hdr_idx.v);
+               pool_free2(s->fe->hdr_idx_pool, txn->hdr_idx.v);
 
        if (txn->rsp.cap != NULL) {
                struct cap_hdr *h;