]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: init: use initcall for all fixed size pool creations
authorWilly Tarreau <w@1wt.eu>
Mon, 26 Nov 2018 10:58:30 +0000 (11:58 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 26 Nov 2018 18:50:32 +0000 (19:50 +0100)
This commit replaces the explicit pool creation that are made in
constructors with a pool registration. Not only this simplifies the
pools declaration (it can be done on a single line after the head is
declared), but it also removes references to pools from within
constructors. The only remaining create_pool() calls are those
performed in init functions after the config is parsed, so there
is no more user of potentially uninitialized pool now.

It has been the opportunity to remove no less than 12 constructors
and 6 init functions.

26 files changed:
include/proto/connection.h
include/proto/filters.h
include/proto/proto_http.h
include/proto/queue.h
include/proto/session.h
src/cache.c
src/checks.c
src/compression.c
src/connection.c
src/dns.c
src/filters.c
src/flt_http_comp.c
src/flt_spoe.c
src/haproxy.c
src/hlua.c
src/mux_h1.c
src/mux_h2.c
src/mux_pt.c
src/pipe.c
src/proto_http.c
src/queue.c
src/session.c
src/signal.c
src/stream.c
src/task.c
src/vars.c

index 11d4aa47d374a346fe99fd746f43e6e20928a10d..a1b979e295bcf1198f77a38e7d56c96e689490fd 100644 (file)
@@ -36,9 +36,6 @@ extern struct pool_head *pool_head_connstream;
 extern struct xprt_ops *registered_xprt[XPRT_ENTRIES];
 extern struct mux_proto_list mux_proto_list;
 
-/* perform minimal intializations, report 0 in case of error, 1 if OK. */
-int init_connection();
-
 /* I/O callback for fd-based connections. It calls the read/write handlers
  * provided by the connection's sock_ops.
  */
index d16f70651c98624db9bc7f0941aa0cde670c1362..2ad0f49976c25e8ac5d1679c36288f10981aa279 100644 (file)
@@ -93,8 +93,6 @@
                                FLT_STRM_DATA_CB_IMPL_2(strm, chn, call, ##__VA_ARGS__), \
                                FLT_STRM_DATA_CB_IMPL_1(strm, chn, call, ##__VA_ARGS__))
 
-extern struct pool_head *pool_head_filter;
-
 void flt_deinit(struct proxy *p);
 int  flt_check(struct proxy *p);
 
index 0d3d7df059a720169901b46d8bf1bae2d24f77a7..7546f019704f51751c1d484f32d028952a695220 100644 (file)
@@ -90,7 +90,6 @@ void manage_server_side_cookies(struct stream *s, struct channel *rtr);
 void check_request_for_cacheability(struct stream *s, struct channel *chn);
 void check_response_for_cacheability(struct stream *s, struct channel *rtr);
 int stats_check_uri(struct stream_interface *si, struct http_txn *txn, struct proxy *backend);
-void init_proto_http();
 int http_find_full_header2(const char *name, int len,
                            char *sol, struct hdr_idx *idx,
                            struct hdr_ctx *ctx);
index 28709fa996381b274f7e1aa2c64f85d789507668..a7ab63b35e27ea3f4e39f80a44957662dab86a59 100644 (file)
@@ -36,7 +36,6 @@
 
 extern struct pool_head *pool_head_pendconn;
 
-int init_pendconn();
 struct pendconn *pendconn_add(struct stream *strm);
 int pendconn_dequeue(struct stream *strm);
 void process_srv_queue(struct server *s);
index f48c0d4f44ab0bebf3eb4946c94f53cb5a9b25b2..68f5c0d0d92645c3d042d3d77b0ad0c82fc81f00 100644 (file)
@@ -35,7 +35,6 @@
 extern struct pool_head *pool_head_session;
 struct session *session_new(struct proxy *fe, struct listener *li, enum obj_type *origin);
 void session_free(struct session *sess);
-int init_session();
 int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr);
 
 /* Remove the refcount from the session to the tracked counters, and clear the
index 7f1de9f3261a837994f84ca9a2d4bda986827cb9..1bf996b5c06c56bb7e8cdd7fe259d053f27610c8 100644 (file)
@@ -40,8 +40,6 @@
 
 static const char *cache_store_flt_id = "cache store filter";
 
-static struct pool_head *pool_head_cache_st = NULL;
-
 struct applet http_cache_applet;
 
 struct flt_ops cache_ops;
@@ -79,6 +77,8 @@ struct cache_entry {
 static struct list caches = LIST_HEAD_INIT(caches);
 static struct cache *tmp_cache_config = NULL;
 
+DECLARE_STATIC_POOL(pool_head_cache_st, "cache_st", sizeof(struct cache_st));
+
 struct cache_entry *entry_exist(struct cache *cache, char *hash)
 {
        struct eb32_node *node;
@@ -1212,12 +1212,6 @@ struct applet http_cache_applet = {
        .release = http_cache_applet_release,
 };
 
-__attribute__((constructor))
-static void __cache_init(void)
-{
-       pool_head_cache_st = create_pool("cache_st", sizeof(struct cache_st), MEM_F_SHARED);
-}
-
 /* config parsers for this section */
 REGISTER_CONFIG_SECTION("cache", cfg_parse_cache, cfg_post_parse_section_cache);
 REGISTER_CONFIG_POSTPARSER("cache", cfg_cache_postparser);
index 55efb8066598969236b604b7b77896d30b3207b4..282ed88a3f471696467064e14721d7a0e49c6e23 100644 (file)
@@ -72,8 +72,8 @@ static void __event_srv_chk_w(struct conn_stream *cs);
 static int wake_srv_chk(struct conn_stream *cs);
 static void __event_srv_chk_r(struct conn_stream *cs);
 
-static struct pool_head *pool_head_email_alert   = NULL;
-static struct pool_head *pool_head_tcpcheck_rule = NULL;
+DECLARE_STATIC_POOL(pool_head_email_alert,   "email_alert",   sizeof(struct email_alert));
+DECLARE_STATIC_POOL(pool_head_tcpcheck_rule, "tcpcheck_rule", sizeof(struct tcpcheck_rule));
 
 
 static const struct check_status check_statuses[HCHK_STATUS_SIZE] = {
@@ -3514,13 +3514,6 @@ int srv_check_healthcheck_port(struct check *chk)
        return 0;
 }
 
-__attribute__((constructor))
-static void __check_init(void)
-{
-       pool_head_email_alert   = create_pool("email_alert",   sizeof(struct email_alert),   MEM_F_SHARED);
-       pool_head_tcpcheck_rule = create_pool("tcpcheck_rule", sizeof(struct tcpcheck_rule), MEM_F_SHARED);
-}
-
 REGISTER_POST_CHECK(start_checks);
 
 /*
index 218a28486854639e90ea09f435d9bd4e11adadf5..b0307b23ebdba17c5e748052cf754192863c5822 100644 (file)
@@ -146,7 +146,8 @@ int comp_append_algo(struct comp *comp, const char *algo)
 }
 
 #if defined(USE_ZLIB) || defined(USE_SLZ)
-static struct pool_head *pool_comp_ctx = NULL;
+DECLARE_STATIC_POOL(pool_comp_ctx, "comp_ctx", sizeof(struct comp_ctx));
+
 /*
  * Alloc the comp_ctx
  */
@@ -710,10 +711,6 @@ static void __comp_fetch_init(void)
        slz_prepare_dist_table();
 #endif
 
-#if defined(USE_ZLIB) || defined(USE_SLZ)
-       pool_comp_ctx = create_pool("comp_ctx", sizeof(struct comp_ctx), MEM_F_SHARED);
-#endif
-
 #if defined(USE_ZLIB) && defined(DEFAULT_MAXZLIBMEM)
        global.maxzlibmem = DEFAULT_MAXZLIBMEM * 1024U * 1024U;
 #endif
index 621477557d2cdfe3fb7e99fa0df898d8aab72b17..054e1998fd2e7c2769322f5062236817bd58adf6 100644 (file)
@@ -30,8 +30,9 @@
 #include <proto/ssl_sock.h>
 #endif
 
-struct pool_head *pool_head_connection;
-struct pool_head *pool_head_connstream;
+DECLARE_POOL(pool_head_connection, "connection",  sizeof(struct connection));
+DECLARE_POOL(pool_head_connstream, "conn_stream", sizeof(struct conn_stream));
+
 struct xprt_ops *registered_xprt[XPRT_ENTRIES] = { NULL, };
 
 /* List head of all known muxes for PROTO */
@@ -39,25 +40,6 @@ struct mux_proto_list mux_proto_list = {
         .list = LIST_HEAD_INIT(mux_proto_list.list)
 };
 
-/* perform minimal intializations, report 0 in case of error, 1 if OK. */
-int init_connection()
-{
-       pool_head_connection = create_pool("connection", sizeof (struct connection), MEM_F_SHARED);
-       if (!pool_head_connection)
-               goto fail_conn;
-
-       pool_head_connstream = create_pool("conn_stream", sizeof(struct conn_stream), MEM_F_SHARED);
-       if (!pool_head_connstream)
-               goto fail_cs;
-
-       return 1;
- fail_cs:
-       pool_destroy(pool_head_connection);
-       pool_head_connection = NULL;
- fail_conn:
-       return 0;
-}
-
 /* I/O callback for fd-based connections. It calls the read/write handlers
  * provided by the connection's sock_ops, which must be valid.
  */
index 2aac74ffe32d1b522e4e40d3446ad31bf7e44fc7..10ccf873fbc6e72aa076b29c12efef8fe60da161 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -48,8 +48,10 @@ struct list dns_resolvers  = LIST_HEAD_INIT(dns_resolvers);
 struct list dns_srvrq_list = LIST_HEAD_INIT(dns_srvrq_list);
 
 static THREAD_LOCAL int64_t dns_query_id_seed = 0; /* random seed */
-static struct pool_head *dns_answer_item_pool = NULL;
-static struct pool_head *dns_resolution_pool  = NULL;
+
+DECLARE_STATIC_POOL(dns_answer_item_pool, "dns_answer_item", sizeof(struct dns_answer_item));
+DECLARE_STATIC_POOL(dns_resolution_pool,  "dns_resolution",  sizeof(struct dns_resolution));
+
 static unsigned int resolution_uuid = 1;
 
 /* Returns a pointer to the resolvers matching the id <id>. NULL is returned if
@@ -2053,12 +2055,5 @@ static struct cli_kw_list cli_kws = {{ }, {
 
 INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
 
-__attribute__((constructor))
-static void __dns_init(void)
-{
-       dns_answer_item_pool = create_pool("dns_answer_item", sizeof(struct dns_answer_item), MEM_F_SHARED);
-       dns_resolution_pool  = create_pool("dns_resolution",  sizeof(struct dns_resolution),  MEM_F_SHARED);
-}
-
 REGISTER_POST_DEINIT(dns_deinit);
 REGISTER_CONFIG_POSTPARSER("dns runtime resolver", dns_finalize_config);
index 1c47256040b47a6d0b860846e392b083606ad617..7b5700d497bad34d861b30f93fa95f231737f7e5 100644 (file)
@@ -32,7 +32,7 @@
 #include <proto/stream_interface.h>
 
 /* Pool used to allocate filters */
-struct pool_head *pool_head_filter = NULL;
+DECLARE_STATIC_POOL(pool_head_filter, "filter", sizeof(struct filter));
 
 static int handle_analyzer_result(struct stream *s, struct channel *chn, unsigned int an_bit, int ret);
 
@@ -1192,13 +1192,6 @@ static struct cfg_kw_list cfg_kws = {ILH, {
 
 INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
 
-__attribute__((constructor))
-static void
-__filters_init(void)
-{
-        pool_head_filter = create_pool("filter", sizeof(struct filter), MEM_F_SHARED);
-}
-
 __attribute__((destructor))
 static void
 __filters_deinit(void)
index e0cee75b4f479fb0df4fca92df1fdbc0d54d7365..1cf3b4d700538eba4ac6ffa1793cd1846d1c793f 100644 (file)
@@ -33,14 +33,6 @@ static const char *http_comp_flt_id = "compression filter";
 
 struct flt_ops comp_ops;
 
-
-/* Pools used to allocate comp_state structs */
-static struct pool_head *pool_head_comp_state = NULL;
-
-static THREAD_LOCAL struct buffer tmpbuf;
-static THREAD_LOCAL struct buffer zbuf;
-static THREAD_LOCAL unsigned int buf_output;
-
 struct comp_state {
        struct comp_ctx  *comp_ctx;   /* compression context */
        struct comp_algo *comp_algo;  /* compression algorithm if not NULL */
@@ -51,6 +43,13 @@ struct comp_state {
        int finished;
 };
 
+/* Pools used to allocate comp_state structs */
+DECLARE_STATIC_POOL(pool_head_comp_state, "comp_state", sizeof(struct comp_state));
+
+static THREAD_LOCAL struct buffer tmpbuf;
+static THREAD_LOCAL struct buffer zbuf;
+static THREAD_LOCAL unsigned int buf_output;
+
 static int select_compression_request_header(struct comp_state *st,
                                             struct stream *s,
                                             struct http_msg *msg);
@@ -1014,10 +1013,3 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
 };
 
 INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords);
-
-__attribute__((constructor))
-static void
-__flt_http_comp_init(void)
-{
-       pool_head_comp_state = create_pool("comp_state", sizeof(struct comp_state), MEM_F_SHARED);
-}
index aa9d8750f855df8cde0f297e89fae1e8456c9866..8d630815b2a267739493b6f3a65ca56abede1d9d 100644 (file)
@@ -101,8 +101,8 @@ int curpxopts;
 int curpxopts2;
 
 /* Pools used to allocate SPOE structs */
-static struct pool_head *pool_head_spoe_ctx = NULL;
-static struct pool_head *pool_head_spoe_appctx = NULL;
+DECLARE_STATIC_POOL(pool_head_spoe_ctx,    "spoe_ctx",    sizeof(struct spoe_context));
+DECLARE_STATIC_POOL(pool_head_spoe_appctx, "spoe_appctx", sizeof(struct spoe_appctx));
 
 struct flt_ops spoe_ops;
 
@@ -4677,13 +4677,6 @@ static struct action_kw_list http_res_action_kws = { { }, {
 
 INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_action_kws);
 
-__attribute__((constructor))
-static void __spoe_init(void)
-{
-       pool_head_spoe_ctx = create_pool("spoe_ctx", sizeof(struct spoe_context), MEM_F_SHARED);
-       pool_head_spoe_appctx = create_pool("spoe_appctx", sizeof(struct spoe_appctx), MEM_F_SHARED);
-}
-
 __attribute__((destructor))
 static void
 __spoe_deinit(void)
index 184225d95e9ea9811bad4917e9a9eca3a4142775..6ec9bcc846bf7fc80aaaf0f9dc164397988f438c 100644 (file)
@@ -1432,16 +1432,12 @@ static void init(int argc, char **argv)
                exit(1);
        init_task();
        init_stream();
-       init_session();
-       init_connection();
        /* warning, we init buffers later */
-       init_pendconn();
        if (!init_http(&err_msg)) {
                ha_alert("%s. Aborting.\n", err_msg);
                free(err_msg);
                abort();
        }
-       init_proto_http();
 
        /* Initialise lua. */
        hlua_init();
index 379eef691c0a4ccbee778bbc3ad40b5d1b482f0c..0e105059deeedaa30ff47f343d71d72776c84f24 100644 (file)
@@ -164,7 +164,7 @@ struct hlua gL;
 /* This is the memory pool containing struct lua for applets
  * (including cli).
  */
-struct pool_head *pool_head_hlua;
+DECLARE_STATIC_POOL(pool_head_hlua, "hlua", sizeof(struct hlua));
 
 /* Used for Socket connection. */
 static struct proxy socket_proxy;
@@ -7670,9 +7670,6 @@ void hlua_init(void)
        };
 #endif
 
-       /* Initialise struct hlua and com signals pool */
-       pool_head_hlua = create_pool("hlua", sizeof(struct hlua), MEM_F_SHARED);
-
        /* Init main lua stack. */
        gL.Mref = LUA_REFNIL;
        gL.flags = 0;
index 252395f09defab6175251503d80cfb0ee80c9152..a845a24165eabdd8269ed43b1067724241428246 100644 (file)
@@ -96,8 +96,8 @@ struct h1s {
 };
 
 /* the h1c and h1s pools */
-static struct pool_head *pool_head_h1c;
-static struct pool_head *pool_head_h1s;
+DECLARE_STATIC_POOL(pool_head_h1c, "h1c", sizeof(struct h1c));
+DECLARE_STATIC_POOL(pool_head_h1s, "h1s", sizeof(struct h1s));
 
 static int h1_recv(struct h1c *h1c);
 static int h1_send(struct h1c *h1c);
@@ -1832,13 +1832,6 @@ static void __h1_deinit(void)
        pool_destroy(pool_head_h1s);
 }
 
-__attribute__((constructor))
-static void __h1_init(void)
-{
-       pool_head_h1c = create_pool("h1c", sizeof(struct h1c), MEM_F_SHARED);
-       pool_head_h1s = create_pool("h1s", sizeof(struct h1s), MEM_F_SHARED);
-}
-
 REGISTER_POST_DEINIT(__h1_deinit);
 
 /*
index e4005a2c366a3947d7f4bc925fdbd6f4d91619f1..a30de3d047081a8543cf8c12a3864e544ec358ff 100644 (file)
 static const struct h2s *h2_closed_stream;
 static const struct h2s *h2_idle_stream;
 
-/* the h2c connection pool */
-static struct pool_head *pool_head_h2c;
-/* the h2s stream pool */
-static struct pool_head *pool_head_h2s;
-
 /* Connection flags (32 bit), in h2c->flags */
 #define H2_CF_NONE              0x00000000
 
@@ -200,6 +195,12 @@ struct h2_fh {
        uint8_t ff;         /* frame flags */
 };
 
+/* the h2c connection pool */
+DECLARE_STATIC_POOL(pool_head_h2c, "h2c", sizeof(struct h2c));
+
+/* the h2s stream pool */
+DECLARE_STATIC_POOL(pool_head_h2s, "h2s", sizeof(struct h2s));
+
 /* a few settings from the global section */
 static int h2_settings_header_table_size      =  4096; /* initial value */
 static int h2_settings_initial_window_size    = 65535; /* initial value */
@@ -3851,11 +3852,4 @@ static void __h2_deinit(void)
        pool_destroy(pool_head_h2c);
 }
 
-__attribute__((constructor))
-static void __h2_init(void)
-{
-       pool_head_h2c = create_pool("h2c", sizeof(struct h2c), MEM_F_SHARED);
-       pool_head_h2s = create_pool("h2s", sizeof(struct h2s), MEM_F_SHARED);
-}
-
 REGISTER_POST_DEINIT(__h2_deinit);
index 8e9c651fde71ce3e6c8c701e410798ebf173944d..5a80848bec96fd80ece38c33c0057e1cb0a0a898 100644 (file)
 #include <proto/stream.h>
 #include <proto/task.h>
 
-static struct pool_head *pool_head_pt_ctx;
-
 struct mux_pt_ctx {
        struct conn_stream *cs;
        struct connection *conn;
        struct wait_event wait_event;
 };
 
+DECLARE_STATIC_POOL(pool_head_pt_ctx, "mux_pt", sizeof(struct mux_pt_ctx));
+
 static void mux_pt_destroy(struct mux_pt_ctx *ctx)
 {
        struct connection *conn = ctx->conn;
@@ -318,10 +318,3 @@ static struct mux_proto_list mux_proto_pt =
        { .token = IST(""), .mode = PROTO_MODE_ANY, .side = PROTO_SIDE_BOTH, .mux = &mux_pt_ops };
 
 INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_pt);
-
-__attribute__((constructor))
-static void __mux_pt_init(void)
-{
-       pool_head_pt_ctx = create_pool("mux_pt", sizeof(struct mux_pt_ctx),
-           MEM_F_SHARED);
-}
index a82283a930acd9b780391a17c7ff20f4da830e92..89b5c9a5f97c8e26277365283eae91b4870c2d14 100644 (file)
@@ -20,7 +20,8 @@
 #include <types/global.h>
 #include <types/pipe.h>
 
-struct pool_head *pool_head_pipe = NULL;
+DECLARE_STATIC_POOL(pool_head_pipe, "pipe", sizeof(struct pipe));
+
 struct pipe *pipes_live = NULL; /* pipes which are still ready to use */
 
 __decl_spinlock(pipes_lock); /* lock used to protect pipes list */
@@ -28,12 +29,6 @@ __decl_spinlock(pipes_lock); /* lock used to protect pipes list */
 int pipes_used = 0;             /* # of pipes in use (2 fds each) */
 int pipes_free = 0;             /* # of pipes unused */
 
-/* allocate memory for the pipes */
-static void init_pipe()
-{
-       pool_head_pipe = create_pool("pipe", sizeof(struct pipe), MEM_F_SHARED);
-}
-
 /* return a pre-allocated empty pipe. Try to allocate one if there isn't any
  * left. NULL is returned if a pipe could not be allocated.
  */
@@ -115,13 +110,6 @@ void put_pipe(struct pipe *p)
        HA_SPIN_UNLOCK(PIPES_LOCK, &pipes_lock);
 }
 
-
-__attribute__((constructor))
-static void __pipe_module_init(void)
-{
-       init_pipe();
-}
-
 /*
  * Local variables:
  *  c-indent-level: 8
index 019556cc912e5c10667cb7f36c7f34a39e275486..eb898a771a4f4c6a1c0092ccec1556624e05ff47 100644 (file)
@@ -87,13 +87,6 @@ const char *stat_status_codes[STAT_STATUS_SIZE] = {
        [STAT_STATUS_UNKN] = "UNKN",
 };
 
-void init_proto_http()
-{
-       /* memory allocations */
-       pool_head_http_txn = create_pool("http_txn", sizeof(struct http_txn), MEM_F_SHARED);
-       pool_head_uniqueid = create_pool("uniqueid", UNIQUEID_LEN, MEM_F_SHARED);
-}
-
 /*
  * Adds a header and its CRLF at the tail of the message's buffer, just before
  * the last CRLF. <len> bytes are copied, not counting the CRLF.
@@ -584,10 +577,12 @@ void http_return_srv_error(struct stream *s, struct stream_interface *si)
 extern const char sess_term_cond[8];
 extern const char sess_fin_state[8];
 extern const char *monthname[12];
-struct pool_head *pool_head_http_txn;
-struct pool_head *pool_head_requri;
+
+DECLARE_POOL(pool_head_http_txn, "http_txn", sizeof(struct http_txn));
+DECLARE_POOL(pool_head_uniqueid, "uniqueid", UNIQUEID_LEN);
+
+struct pool_head *pool_head_requri = NULL;
 struct pool_head *pool_head_capture = NULL;
-struct pool_head *pool_head_uniqueid;
 
 /*
  * Capture headers from message starting at <som> according to header list
@@ -7952,12 +7947,6 @@ void http_set_status(unsigned int status, const char *reason, struct stream *s)
        http_msg_move_end(&txn->rsp, delta);
 }
 
-__attribute__((constructor))
-static void __http_protocol_init(void)
-{
-}
-
-
 /*
  * Local variables:
  *  c-indent-level: 8
index fa02b4adb036890693331b48854a23616c46ccf9..2e6de98edda9d80c43b3d05ca36e44689e582e87 100644 (file)
 #define KEY_CLASS_OFFSET_BOUNDARY(key) (KEY_CLASS(key) | NOW_OFFSET_BOUNDARY())
 #define MAKE_KEY(class, offset)        (((u32)(class + 0x7ff) << 20) | ((u32)(now_ms + offset) & 0xfffff))
 
-struct pool_head *pool_head_pendconn;
-
-/* perform minimal intializations, report 0 in case of error, 1 if OK. */
-int init_pendconn()
-{
-       pool_head_pendconn = create_pool("pendconn", sizeof(struct pendconn), MEM_F_SHARED);
-       return pool_head_pendconn != NULL;
-}
+DECLARE_POOL(pool_head_pendconn, "pendconn", sizeof(struct pendconn));
 
 /* returns the effective dynamic maxconn for a server, considering the minconn
  * and the proxy's usage relative to its dynamic connections limit. It is
index 8d9e83609960abd1f55c4d5b4a8caf4ccdb0a8c1..29f92438b5340afe8eabeb2d5300d995e4f5a5df 100644 (file)
@@ -28,7 +28,7 @@
 #include <proto/tcp_rules.h>
 #include <proto/vars.h>
 
-struct pool_head *pool_head_session;
+DECLARE_POOL(pool_head_session, "session", sizeof(struct session));
 
 static int conn_complete_session(struct connection *conn);
 static struct task *session_expire_embryonic(struct task *t, void *context, unsigned short state);
@@ -100,13 +100,6 @@ void conn_session_free(struct connection *conn)
        session_free(conn->owner);
 }
 
-/* perform minimal intializations, report 0 in case of error, 1 if OK. */
-int init_session()
-{
-       pool_head_session = create_pool("session", sizeof(struct session), MEM_F_SHARED);
-       return pool_head_session != NULL;
-}
-
 /* count a new session to keep frontend, listener and track stats up to date */
 static void session_count_new(struct session *sess)
 {
index 93877284c59c8e5102d702500d555c5c60f4dc6b..4ee55024f736bc86599a84baba9195dd9df2bd1c 100644 (file)
 int signal_queue_len; /* length of signal queue, <= MAX_SIGNAL (1 entry per signal max) */
 int signal_queue[MAX_SIGNAL];                     /* in-order queue of received signals */
 struct signal_descriptor signal_state[MAX_SIGNAL];
-struct pool_head *pool_head_sig_handlers = NULL;
 sigset_t blocked_sig;
 int signal_pending = 0; /* non-zero if t least one signal remains unprocessed */
 
+DECLARE_POOL(pool_head_sig_handlers, "sig_handlers", sizeof(struct sig_handler));
 
 /* Common signal handler, used by all signals. Received signals are queued.
  * Signal number zero has a specific status, as it cannot be delivered by the
@@ -122,8 +122,7 @@ int signal_init()
        for (sig = 0; sig < MAX_SIGNAL; sig++)
                LIST_INIT(&signal_state[sig].handlers);
 
-       pool_head_sig_handlers = create_pool("sig_handlers", sizeof(struct sig_handler), MEM_F_SHARED);
-       return pool_head_sig_handlers != NULL;
+       return 1;
 }
 
 /*
index 6b097c3257dec4da4071cf2c8e9e74a5017ec84d..da59cf127f2cdcebef00b12055912bb177b72f33 100644 (file)
@@ -63,7 +63,8 @@
 #include <proto/tcp_rules.h>
 #include <proto/vars.h>
 
-struct pool_head *pool_head_stream;
+DECLARE_POOL(pool_head_stream, "stream", sizeof(struct stream));
+
 struct list streams;
 __decl_spinlock(streams_lock);
 
@@ -515,8 +516,8 @@ void stream_release_buffers(struct stream *s)
 int init_stream()
 {
        LIST_INIT(&streams);
-       pool_head_stream = create_pool("stream", sizeof(struct stream), MEM_F_SHARED);
-       return pool_head_stream != NULL;
+
+       return 1;
 }
 
 void stream_process_counters(struct stream *s)
index ef1db82b6286caf322ba1a6490b782e0d903a16d..aeb3e4e2c665fe024b17725d38ec9548e8e78bb9 100644 (file)
 #include <proto/task.h>
 #include <proto/fd.h>
 
-struct pool_head *pool_head_task;
-struct pool_head *pool_head_tasklet;
+DECLARE_POOL(pool_head_task,    "task",    sizeof(struct task));
+DECLARE_POOL(pool_head_tasklet, "tasklet", sizeof(struct tasklet));
 
 /* This is the memory pool containing all the signal structs. These
  * struct are used to store each required signal between two tasks.
  */
-struct pool_head *pool_head_notification;
+DECLARE_POOL(pool_head_notification, "notification", sizeof(struct notification));
 
 unsigned int nb_tasks = 0;
 volatile unsigned long active_tasks_mask = 0; /* Mask of threads with active tasks */
@@ -482,15 +482,6 @@ int init_task()
        for (i = 0; i < MAX_THREADS; i++) {
                LIST_INIT(&task_per_thread[i].task_list);
        }
-       pool_head_task = create_pool("task", sizeof(struct task), MEM_F_SHARED);
-       if (!pool_head_task)
-               return 0;
-       pool_head_tasklet = create_pool("tasklet", sizeof(struct tasklet), MEM_F_SHARED);
-       if (!pool_head_tasklet)
-               return 0;
-       pool_head_notification = create_pool("notification", sizeof(struct notification), MEM_F_SHARED);
-       if (!pool_head_notification)
-               return 0;
        return 1;
 }
 
index 2bc46b164366e58d68998957cdb656574afe0a86..0b642683cb031bb56677972d9d8beb6db409f177 100644 (file)
@@ -16,7 +16,7 @@
 #include <proto/vars.h>
 
 /* This contains a pool of struct vars */
-static struct pool_head *var_pool = NULL;
+DECLARE_STATIC_POOL(var_pool, "vars", sizeof(struct var));
 
 /* This array contain all the names of all the HAProxy vars.
  * This permits to identify two variables name with
@@ -921,9 +921,3 @@ static struct cfg_kw_list cfg_kws = {{ },{
 }};
 
 INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
-
-__attribute__((constructor))
-static void __vars_init(void)
-{
-       var_pool = create_pool("vars", sizeof(struct var), MEM_F_SHARED);
-}