MEDIUM: init: use initcall for all fixed size pool creations

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.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index 11d4aa4..a1b979e 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -36,9 +36,6 @@
 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.
  */
diff --git a/include/proto/filters.h b/include/proto/filters.h
index d16f706..2ad0f49 100644
--- a/include/proto/filters.h
+++ b/include/proto/filters.h
@@ -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);
 
diff --git a/include/proto/proto_http.h b/include/proto/proto_http.h
index 0d3d7df..7546f01 100644
--- a/include/proto/proto_http.h
+++ b/include/proto/proto_http.h
@@ -90,7 +90,6 @@
 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);
diff --git a/include/proto/queue.h b/include/proto/queue.h
index 28709fa..a7ab63b 100644
--- a/include/proto/queue.h
+++ b/include/proto/queue.h
@@ -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);
diff --git a/include/proto/session.h b/include/proto/session.h
index f48c0d4..68f5c0d 100644
--- a/include/proto/session.h
+++ b/include/proto/session.h
@@ -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
diff --git a/src/cache.c b/src/cache.c
index 7f1de9f..1bf996b 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -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 @@
 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 @@
 	.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);
diff --git a/src/checks.c b/src/checks.c
index 55efb80..282ed88 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -72,8 +72,8 @@
 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 @@
 	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);
 
 /*
diff --git a/src/compression.c b/src/compression.c
index 218a284..b0307b2 100644
--- a/src/compression.c
+++ b/src/compression.c
@@ -146,7 +146,8 @@
 }
 
 #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 @@
 	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
diff --git a/src/connection.c b/src/connection.c
index 6214775..054e199 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -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 @@
         .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.
  */
diff --git a/src/dns.c b/src/dns.c
index 2aac74f..10ccf87 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -48,8 +48,10 @@
 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 @@
 
 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);
diff --git a/src/filters.c b/src/filters.c
index 1c47256..7b5700d 100644
--- a/src/filters.c
+++ b/src/filters.c
@@ -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 @@
 
 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)
diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c
index e0cee75..1cf3b4d 100644
--- a/src/flt_http_comp.c
+++ b/src/flt_http_comp.c
@@ -33,14 +33,6 @@
 
 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 @@
 	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 @@
 };
 
 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);
-}
diff --git a/src/flt_spoe.c b/src/flt_spoe.c
index aa9d875..8d63081 100644
--- a/src/flt_spoe.c
+++ b/src/flt_spoe.c
@@ -101,8 +101,8 @@
 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 @@
 
 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)
diff --git a/src/haproxy.c b/src/haproxy.c
index 184225d..6ec9bcc 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1432,16 +1432,12 @@
 		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();
diff --git a/src/hlua.c b/src/hlua.c
index 379eef6..0e10505 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -164,7 +164,7 @@
 /* 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 @@
 	};
 #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;
diff --git a/src/mux_h1.c b/src/mux_h1.c
index 252395f..a845a24 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -96,8 +96,8 @@
 };
 
 /* 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 @@
 	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);
 
 /*
diff --git a/src/mux_h2.c b/src/mux_h2.c
index e4005a2..a30de3d 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -29,11 +29,6 @@
 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 @@
 	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 @@
 	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);
diff --git a/src/mux_pt.c b/src/mux_pt.c
index 8e9c651..5a80848 100644
--- a/src/mux_pt.c
+++ b/src/mux_pt.c
@@ -16,14 +16,14 @@
 #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 @@
 	{ .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);
-}
diff --git a/src/pipe.c b/src/pipe.c
index a82283a..89b5c9a 100644
--- a/src/pipe.c
+++ b/src/pipe.c
@@ -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 @@
 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 @@
 	HA_SPIN_UNLOCK(PIPES_LOCK, &pipes_lock);
 }
 
-
-__attribute__((constructor))
-static void __pipe_module_init(void)
-{
-	init_pipe();
-}
-
 /*
  * Local variables:
  *  c-indent-level: 8
diff --git a/src/proto_http.c b/src/proto_http.c
index 019556c..eb898a7 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -87,13 +87,6 @@
 	[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 @@
 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 @@
 	http_msg_move_end(&txn->rsp, delta);
 }
 
-__attribute__((constructor))
-static void __http_protocol_init(void)
-{
-}
-
-
 /*
  * Local variables:
  *  c-indent-level: 8
diff --git a/src/queue.c b/src/queue.c
index fa02b4a..2e6de98 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -93,14 +93,7 @@
 #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
diff --git a/src/session.c b/src/session.c
index 8d9e836..29f9243 100644
--- a/src/session.c
+++ b/src/session.c
@@ -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 @@
 	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)
 {
diff --git a/src/signal.c b/src/signal.c
index 9387728..4ee5502 100644
--- a/src/signal.c
+++ b/src/signal.c
@@ -29,10 +29,10 @@
 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 @@
 	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;
 }
 
 /*
diff --git a/src/stream.c b/src/stream.c
index 6b097c3..da59cf1 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -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 @@
 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)
diff --git a/src/task.c b/src/task.c
index ef1db82..aeb3e4e 100644
--- a/src/task.c
+++ b/src/task.c
@@ -25,13 +25,13 @@
 #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 @@
 	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;
 }
 
diff --git a/src/vars.c b/src/vars.c
index 2bc46b1..0b64268 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -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 @@
 }};
 
 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);
-}