[MAJOR] last bunch of capture changes for mempool v2
The header captures had lots of pools. They have all been transformed.
diff --git a/include/common/memory.h b/include/common/memory.h
index c50ab9a..45ac7f9 100644
--- a/include/common/memory.h
+++ b/include/common/memory.h
@@ -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
diff --git a/include/types/capture.h b/include/types/capture.h
index 49f4d53..e37cc48 100644
--- a/include/types/capture.h
+++ b/include/types/capture.h
@@ -31,7 +31,7 @@
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;
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 532348e..9be81d5 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -140,7 +140,8 @@
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 */
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 6dd7ab6..b532ce9 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -824,6 +824,7 @@
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 @@
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 @@
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.
diff --git a/src/client.c b/src/client.c
index 6a1a3df..38815e7 100644
--- a/src/client.c
+++ b/src/client.c
@@ -233,9 +233,8 @@
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 @@
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 @@
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 @@
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 @@
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);
diff --git a/src/haproxy.c b/src/haproxy.c
index 3442389..4e22e19 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -616,7 +616,7 @@
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 @@
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 @@
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) */
diff --git a/src/proto_http.c b/src/proto_http.c
index 64ab507..4e9e683 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -775,7 +775,7 @@
(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");
diff --git a/src/session.c b/src/session.c
index 38889c4..01073de 100644
--- a/src/session.c
+++ b/src/session.c
@@ -51,17 +51,17 @@
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)