[MAJOR] last bunch of capture changes for mempool v2
The header captures had lots of pools. They have all been transformed.
This commit is contained in:
parent
086b3b4c9f
commit
cf7f320f9d
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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.
|
||||
|
24
src/client.c
24
src/client.c
@ -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);
|
||||
|
@ -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) */
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user