From e4d7e5506133133d3996242ae8e64399d9029406 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 13 May 2007 20:19:55 +0200 Subject: [PATCH] [MAJOR] ported pendconn to mempools v2 A pool_destroy() was also missing in deinit() --- include/proto/queue.h | 3 +++ include/types/queue.h | 4 ---- src/haproxy.c | 4 +++- src/queue.c | 14 +++++++++++--- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/include/proto/queue.h b/include/proto/queue.h index 4370cb39d8..092747a03e 100644 --- a/include/proto/queue.h +++ b/include/proto/queue.h @@ -32,6 +32,9 @@ #include #include +extern struct pool_head *pool2_pendconn; + +int init_pendconn(); struct session *pendconn_get_next_sess(struct server *srv, struct proxy *px); struct pendconn *pendconn_add(struct session *sess); void pendconn_free(struct pendconn *p); diff --git a/include/types/queue.h b/include/types/queue.h index a8e7d8b016..922aa92fd0 100644 --- a/include/types/queue.h +++ b/include/types/queue.h @@ -34,10 +34,6 @@ struct pendconn { struct server *srv; /* the server we are waiting for */ }; -#define sizeof_pendconn sizeof(struct pendconn) -extern void **pool_pendconn; - - #endif /* _TYPES_QUEUE_H */ /* diff --git a/src/haproxy.c b/src/haproxy.c index 59c6149789..c88bffcd4d 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -374,9 +374,10 @@ void init(int argc, char **argv) localtime((time_t *)&now.tv_sec); start_date = now; - init_buffer(); init_task(); init_session(); + init_buffer(); + init_pendconn(); init_proto_http(); cfg_polling_mechanism = POLL_USE_SELECT; /* select() is always available */ @@ -667,6 +668,7 @@ void deinit(void) pool_destroy2(pool2_task); pool_destroy(pool_capture); pool_destroy(pool_appsess); + pool_destroy2(pool2_pendconn); if (have_appsession) { pool_destroy(apools.serverid); diff --git a/src/queue.c b/src/queue.c index 37d3ed8507..a4670a80c3 100644 --- a/src/queue.c +++ b/src/queue.c @@ -11,6 +11,7 @@ */ #include +#include #include #include @@ -21,7 +22,14 @@ #include -void **pool_pendconn = NULL; +struct pool_head *pool2_pendconn; + +/* perform minimal intializations, report 0 in case of error, 1 if OK. */ +int init_pendconn() +{ + pool2_pendconn = create_pool("pendconn", sizeof(struct pendconn), MEM_F_SHARED); + return pool2_pendconn != NULL; +} /* returns the effective dynamic maxconn for a server, considering the minconn * and the proxy's usage relative to its dynamic connections limit. It is @@ -98,7 +106,7 @@ struct pendconn *pendconn_add(struct session *sess) { struct pendconn *p; - p = pool_alloc(pendconn); + p = pool_alloc2(pool2_pendconn); if (!p) return NULL; @@ -136,7 +144,7 @@ void pendconn_free(struct pendconn *p) else p->sess->be->nbpend--; p->sess->be->totpend--; - pool_free(pendconn, p); + pool_free2(pool2_pendconn, p); }