MEDIUM: memory: use pool_destroy_all() to destroy all pools on deinit()

Instead of exporting a number of pools and having to manually delete
them in deinit() or to have dedicated destructors to remove them, let's
simply kill all pools on deinit().

For this a new function pool_destroy_all() was introduced. As its name
implies, it destroys and frees all pools (provided they don't have any
user anymore of course).

This allowed to remove 4 implicit destructors, 2 explicit ones, and 11
individual calls to pool_destroy(). In addition it properly removes
the mux_pt_ctx pool which was not cleared on exit (no backport needed
here since it's 1.9 only). The sig_handler pool doesn't need to be
exported anymore and became static now.
diff --git a/src/buffer.c b/src/buffer.c
index e55c5bd..c4d6140 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -54,11 +54,6 @@
 	return 1;
 }
 
-void deinit_buffer()
-{
-	pool_destroy(pool_head_buffer);
-}
-
 /*
  * Dumps part or all of a buffer.
  */
diff --git a/src/chunk.c b/src/chunk.c
index fa3fb71..e052322 100644
--- a/src/chunk.c
+++ b/src/chunk.c
@@ -102,14 +102,6 @@
 }
 
 /*
- * free the trash buffers
- */
-void deinit_trash_buffers(void)
-{
-	pool_destroy(pool_head_trash);
-}
-
-/*
  * Allocate a trash chunk from the reentrant pool. The buffer starts at the
  * end of the chunk. This chunk must be freed using free_trash_chunk(). This
  * call may fail and the caller is responsible for checking that the returned
diff --git a/src/dns.c b/src/dns.c
index 10ccf87..2a53c03 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -1839,9 +1839,6 @@
 		LIST_DEL(&srvrq->list);
 		free(srvrq);
 	}
-
-	pool_destroy(dns_answer_item_pool);
-	pool_destroy(dns_resolution_pool);
 }
 
 /* Finalizes the DNS configuration by allocating required resources and checking
diff --git a/src/filters.c b/src/filters.c
index 7b5700d..d29a0c0 100644
--- a/src/filters.c
+++ b/src/filters.c
@@ -1192,13 +1192,6 @@
 
 INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
 
-__attribute__((destructor))
-static void
-__filters_deinit(void)
-{
-	pool_destroy(pool_head_filter);
-}
-
 REGISTER_POST_CHECK(flt_init_all);
 REGISTER_PER_THREAD_INIT(flt_init_all_per_thread);
 REGISTER_PER_THREAD_DEINIT(flt_deinit_all_per_thread);
diff --git a/src/flt_spoe.c b/src/flt_spoe.c
index 8d63081..bd351be 100644
--- a/src/flt_spoe.c
+++ b/src/flt_spoe.c
@@ -4676,11 +4676,3 @@
 };
 
 INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_action_kws);
-
-__attribute__((destructor))
-static void
-__spoe_deinit(void)
-{
-	pool_destroy(pool_head_spoe_ctx);
-	pool_destroy(pool_head_spoe_appctx);
-}
diff --git a/src/haproxy.c b/src/haproxy.c
index 6ec9bcc..96715ee 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -2500,7 +2500,6 @@
 	cfg_unregister_sections();
 
 	deinit_log_buffers();
-	deinit_trash_buffers();
 
 	protocol_unbind_all();
 
@@ -2534,20 +2533,7 @@
 	}
 
 	vars_prune(&global.vars, NULL, NULL);
-
-	deinit_buffer();
-
-	pool_destroy(pool_head_stream);
-	pool_destroy(pool_head_session);
-	pool_destroy(pool_head_connection);
-	pool_destroy(pool_head_connstream);
-	pool_destroy(pool_head_requri);
-	pool_destroy(pool_head_task);
-	pool_destroy(pool_head_capture);
-	pool_destroy(pool_head_pendconn);
-	pool_destroy(pool_head_sig_handlers);
-	pool_destroy(pool_head_hdr_idx);
-	pool_destroy(pool_head_http_txn);
+	pool_destroy_all();
 	deinit_pollers();
 } /* end deinit() */
 
diff --git a/src/memory.c b/src/memory.c
index 587702a..6d2eacd 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -436,6 +436,15 @@
 	return NULL;
 }
 
+/* This destroys all pools on exit. It is *not* thread safe. */
+void pool_destroy_all()
+{
+	struct pool_head *entry, *back;
+
+	list_for_each_entry_safe(entry, back, &pools, list)
+		pool_destroy(entry);
+}
+
 /* This function dumps memory usage information into the trash buffer. */
 void dump_pools_to_trash()
 {
diff --git a/src/mux_h1.c b/src/mux_h1.c
index a845a24..bade571 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -1826,14 +1826,6 @@
 
 INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_htx);
 
-static void __h1_deinit(void)
-{
-	pool_destroy(pool_head_h1c);
-	pool_destroy(pool_head_h1s);
-}
-
-REGISTER_POST_DEINIT(__h1_deinit);
-
 /*
  * Local variables:
  *  c-indent-level: 8
diff --git a/src/mux_h2.c b/src/mux_h2.c
index a30de3d..1971792 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -3845,11 +3845,3 @@
 }};
 
 INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
-
-static void __h2_deinit(void)
-{
-	pool_destroy(pool_head_h2s);
-	pool_destroy(pool_head_h2c);
-}
-
-REGISTER_POST_DEINIT(__h2_deinit);
diff --git a/src/signal.c b/src/signal.c
index 4ee5502..b6ed1a6 100644
--- a/src/signal.c
+++ b/src/signal.c
@@ -32,7 +32,7 @@
 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));
+DECLARE_STATIC_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