mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-23 03:16:47 +00:00
OPTIM/MINOR: move the hdr_idx pools out of the proxy struct
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.
This commit is contained in:
parent
9ed560e964
commit
34eb671f24
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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:
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
@ -11,8 +11,10 @@
|
||||
*/
|
||||
|
||||
#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
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user