]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MAJOR] last bunch of capture changes for mempool v2
authorWilly Tarreau <w@1wt.eu>
Sun, 13 May 2007 20:46:04 +0000 (22:46 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 13 May 2007 20:46:04 +0000 (22:46 +0200)
The header captures had lots of pools. They have all been transformed.

include/common/memory.h
include/types/capture.h
include/types/proxy.h
src/cfgparse.c
src/client.c
src/haproxy.c
src/proto_http.c
src/session.c

index c50ab9a8376914e7a31609ebe661272e6baf20ef..45ac7f962a81ad04c8b9681ea47de37f5f6da843 100644 (file)
@@ -27,7 +27,6 @@
 #include <common/config.h>
 #include <common/mini-clist.h>
 
-#define sizeof_capture  CAPTURE_LEN
 /*
  * Returns a pointer to an area of <__len> bytes taken from the pool <pool> or
  * dynamically allocated. In the first case, <__pool> is updated to point to
index 49f4d535ac18d00da73d347f6ec80ce4517edcf7..e37cc483f93b14a22484e705b5a455fd1d23662e 100644 (file)
@@ -31,7 +31,7 @@ struct cap_hdr {
     int namelen;                       /* length of the header name, to speed-up lookups */
     int len;                           /* capture length, not including terminal zero */
     int index;                         /* index in the output array */
-    void *pool;                                /* pool of pre-allocated memory area of (len+1) bytes */
+    struct pool_head *pool;            /* pool of pre-allocated memory area of (len+1) bytes */
 };
 
 extern struct pool_head *pool2_capture;
index 532348ec9a36ced1169db09773bcd21dcc2a66f1..9be81d59e86387287235c506ebd8a1cbc21cab65 100644 (file)
@@ -140,7 +140,8 @@ struct proxy {
        int nb_req_cap, nb_rsp_cap;             /* # of headers to be captured */
        struct cap_hdr *req_cap;                /* chained list of request headers to be captured */
        struct cap_hdr *rsp_cap;                /* chained list of response headers to be captured */
-       void *req_cap_pool, *rsp_cap_pool;      /* pools of pre-allocated char ** used to build the sessions */
+       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 */
        char *req_add[MAX_NEWHDR], *rsp_add[MAX_NEWHDR]; /* headers to be added */
        int grace;                              /* grace time after stop request */
index 6dd7ab6173afcf2dabb91a5df20ce01f7b9d3b6d..b532ce92d00db5e7a73736b2ac9c4cabb9637e30 100644 (file)
@@ -824,6 +824,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args)
                        hdr->name = strdup(args[3]);
                        hdr->namelen = strlen(args[3]);
                        hdr->len = atol(args[5]);
+                       hdr->pool = create_pool("caphdr", hdr->len + 1, MEM_F_SHARED);
                        hdr->index = curproxy->nb_req_cap++;
                        curproxy->req_cap = hdr;
                        curproxy->to_log |= LW_REQHDR;
@@ -846,6 +847,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args)
                        hdr->name = strdup(args[3]);
                        hdr->namelen = strlen(args[3]);
                        hdr->len = atol(args[5]);
+                       hdr->pool = create_pool("caphdr", hdr->len + 1, MEM_F_SHARED);
                        hdr->index = curproxy->nb_rsp_cap++;
                        curproxy->rsp_cap = hdr;
                        curproxy->to_log |= LW_RSPHDR;
@@ -2401,6 +2403,16 @@ int readcfgfile(const char *file)
                        memcpy(curproxy->check_req, sslv3_client_hello_pkt, sizeof(sslv3_client_hello_pkt));
                }
 
+               /* The small pools required for the capture lists */
+               if (curproxy->nb_req_cap)
+                       curproxy->req_cap_pool = create_pool("ptrcap",
+                                                            curproxy->nb_req_cap * sizeof(char *),
+                                                            MEM_F_SHARED);
+               if (curproxy->nb_rsp_cap)
+                       curproxy->rsp_cap_pool = create_pool("ptrcap",
+                                                            curproxy->nb_rsp_cap * sizeof(char *),
+                                                            MEM_F_SHARED);
+
                /* for backwards compatibility with "listen" instances, if
                 * fullconn is not set but maxconn is set, then maxconn
                 * is used.
index 6a1a3dfb6556e9a08cb4e368e20a50b7222945d9..38815e7712986b10ed1ed88cc0e1c2eaac535864 100644 (file)
@@ -233,9 +233,8 @@ int event_accept(int fd) {
                        txn->hdr_idx.size = MAX_HTTP_HDR;
 
                        if (p->nb_req_cap > 0) {
-                               if ((txn->req.cap =
-                                    pool_alloc_from(p->req_cap_pool, p->nb_req_cap*sizeof(char *)))
-                                   == NULL) { /* no memory */
+                               if ((txn->req.cap = pool_alloc2(p->req_cap_pool)) == NULL) {
+                                       /* no memory */
                                        close(cfd); /* nothing can be done for this fd without memory */
                                        pool_free2(pool2_task, t);
                                        pool_free2(pool2_session, s);
@@ -246,11 +245,10 @@ int event_accept(int fd) {
 
 
                        if (p->nb_rsp_cap > 0) {
-                               if ((txn->rsp.cap =
-                                    pool_alloc_from(p->rsp_cap_pool, p->nb_rsp_cap*sizeof(char *)))
-                                   == NULL) { /* no memory */
+                               if ((txn->rsp.cap = pool_alloc2(p->rsp_cap_pool)) == NULL) {
+                                       /* no memory */
                                        if (txn->req.cap != NULL)
-                                               pool_free_to(p->req_cap_pool, txn->req.cap);
+                                               pool_free2(p->req_cap_pool, txn->req.cap);
                                        close(cfd); /* nothing can be done for this fd without memory */
                                        pool_free2(pool2_task, t);
                                        pool_free2(pool2_session, s);
@@ -264,9 +262,9 @@ int event_accept(int fd) {
                             pool_alloc_from(p->hdr_idx_pool, txn->hdr_idx.size*sizeof(*txn->hdr_idx.v)))
                            == NULL) { /* no memory */
                                if (txn->rsp.cap != NULL)
-                                       pool_free_to(p->rsp_cap_pool, txn->rsp.cap);
+                                       pool_free2(p->rsp_cap_pool, txn->rsp.cap);
                                if (txn->req.cap != NULL)
-                                       pool_free_to(p->req_cap_pool, txn->req.cap);
+                                       pool_free2(p->req_cap_pool, txn->req.cap);
                                close(cfd); /* nothing can be done for this fd without memory */
                                pool_free2(pool2_task, t);
                                pool_free2(pool2_session, s);
@@ -351,9 +349,9 @@ int event_accept(int fd) {
                        if (txn->hdr_idx.v != NULL)
                                pool_free_to(p->hdr_idx_pool, txn->hdr_idx.v);
                        if (txn->rsp.cap != NULL)
-                               pool_free_to(p->rsp_cap_pool, txn->rsp.cap);
+                               pool_free2(p->rsp_cap_pool, txn->rsp.cap);
                        if (txn->req.cap != NULL)
-                               pool_free_to(p->req_cap_pool, txn->req.cap);
+                               pool_free2(p->req_cap_pool, txn->req.cap);
                        close(cfd); /* nothing can be done for this fd without memory */
                        pool_free2(pool2_task, t);
                        pool_free2(pool2_session, s);
@@ -374,9 +372,9 @@ int event_accept(int fd) {
                        if (txn->hdr_idx.v != NULL)
                                pool_free_to(p->hdr_idx_pool, txn->hdr_idx.v);
                        if (txn->rsp.cap != NULL)
-                               pool_free_to(p->rsp_cap_pool, txn->rsp.cap);
+                               pool_free2(p->rsp_cap_pool, txn->rsp.cap);
                        if (txn->req.cap != NULL)
-                               pool_free_to(p->req_cap_pool, txn->req.cap);
+                               pool_free2(p->req_cap_pool, txn->req.cap);
                        close(cfd); /* nothing can be done for this fd without memory */
                        pool_free2(pool2_task, t);
                        pool_free2(pool2_session, s);
index 344238976dc7f93603f85bec4fdef0332cfeca4a..4e22e1920dc527d430839a5d01ef8918f7418f75 100644 (file)
@@ -616,7 +616,7 @@ void deinit(void)
                        h_next = h->next;
                        if (h->name)
                                free(h->name);
-                       pool_destroy(h->pool);
+                       pool_destroy2(h->pool);
                        free(h);
                        h = h_next;
                }/* end while(h) */
@@ -627,7 +627,7 @@ void deinit(void)
                        if (h->name)
                                free(h->name);
            
-                       pool_destroy(h->pool);
+                       pool_destroy2(h->pool);
                        free(h);
                        h = h_next;
                }/* end while(h) */
@@ -652,8 +652,8 @@ void deinit(void)
                        l = l_next;
                }/* end while(l) */
        
-               pool_destroy((void **) p->req_cap_pool);
-               pool_destroy((void **) p->rsp_cap_pool);
+               pool_destroy2(p->req_cap_pool);
+               pool_destroy2(p->rsp_cap_pool);
                p = p->next;
        }/* end while(p) */
     
index 64ab50799e93522c0cbb502ef0088acf38ec8bf6..4e9e68361dfa1eda155ece8ba239c92d35c16499 100644 (file)
@@ -775,7 +775,7 @@ void capture_headers(char *som, struct hdr_idx *idx,
                            (strncasecmp(sol, h->name, h->namelen) == 0)) {
                                if (cap[h->index] == NULL)
                                        cap[h->index] =
-                                               pool_alloc_from(h->pool, h->len + 1);
+                                               pool_alloc2(h->pool);
 
                                if (cap[h->index] == NULL) {
                                        Alert("HTTP capture : out of memory.\n");
index 38889c4e22fb4e8022b0bb938561894e5bf2e0ca..01073de62117bc572066027bbabc09e9ade6ea15 100644 (file)
@@ -51,17 +51,17 @@ void session_free(struct session *s)
                struct cap_hdr *h;
                for (h = s->fe->rsp_cap; h; h = h->next) {
                        if (txn->rsp.cap[h->index] != NULL)
-                               pool_free_to(h->pool, txn->rsp.cap[h->index]);
+                               pool_free2(h->pool, txn->rsp.cap[h->index]);
                }
-               pool_free_to(s->fe->rsp_cap_pool, txn->rsp.cap);
+               pool_free2(s->fe->rsp_cap_pool, txn->rsp.cap);
        }
        if (txn->req.cap != NULL) {
                struct cap_hdr *h;
                for (h = s->fe->req_cap; h; h = h->next) {
                        if (txn->req.cap[h->index] != NULL)
-                               pool_free_to(h->pool, txn->req.cap[h->index]);
+                               pool_free2(h->pool, txn->req.cap[h->index]);
                }
-               pool_free_to(s->fe->req_cap_pool, txn->req.cap);
+               pool_free2(s->fe->req_cap_pool, txn->req.cap);
        }
 
        if (txn->uri)