From c264ea1679f4ad6d4656249e3a5958334b10fbc6 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 6 Aug 2025 16:43:27 +0200 Subject: [PATCH] MEDIUM: tree-wide: replace most DECLARE_POOL with DECLARE_TYPED_POOL This will make the pools size and alignment automatically inherit the type declaration. It was done like this: sed -i -e 's:DECLARE_POOL(\([^,]*,[^,]*,\s*\)sizeof(\([^)]*\))):DECLARE_TYPED_POOL(\1\2):g' $(git grep -lw DECLARE_POOL src addons) sed -i -e 's:DECLARE_STATIC_POOL(\([^,]*,[^,]*,\s*\)sizeof(\([^)]*\))):DECLARE_STATIC_TYPED_POOL(\1\2):g' $(git grep -lw DECLARE_STATIC_POOL src addons) 81 replacements were made. The only remaining ones are those which set their own size without depending on a structure. The few ones with an extra size were manually handled. It also means that the requested alignments are now checked against the type's. Given that none is specified for now, no issue is reported. It was verified with "show pools detailed" that the definitions are exactly the same, and that the binaries are similar. --- addons/promex/service-prometheus.c | 4 ++-- src/applet.c | 2 +- src/cache.c | 2 +- src/compression.c | 2 +- src/connection.c | 10 +++++----- src/dns.c | 4 ++-- src/event_hdl.c | 8 ++++---- src/fcgi-app.c | 6 +++--- src/filters.c | 2 +- src/flt_bwlim.c | 2 +- src/flt_http_comp.c | 2 +- src/flt_spoe.c | 4 ++-- src/h3.c | 4 ++-- src/hlua.c | 6 +++--- src/hlua_fcn.c | 2 +- src/http_ana.c | 2 +- src/lb_fwlc.c | 2 +- src/mux_fcgi.c | 4 ++-- src/mux_h1.c | 4 ++-- src/mux_h2.c | 4 ++-- src/mux_pt.c | 2 +- src/mux_quic.c | 6 +++--- src/mux_spop.c | 4 ++-- src/pipe.c | 2 +- src/queue.c | 2 +- src/quic_ack.c | 2 +- src/quic_conn.c | 9 ++++----- src/quic_frame.c | 4 ++-- src/quic_rx.c | 4 ++-- src/quic_ssl.c | 2 +- src/quic_stream.c | 9 +++------ src/quic_tls.c | 10 +++++----- src/quic_tx.c | 2 +- src/resolvers.c | 6 +++--- src/session.c | 5 ++--- src/signal.c | 2 +- src/ssl_sock.c | 2 +- src/stconn.c | 4 ++-- src/stream.c | 2 +- src/task.c | 6 +++--- src/tcpcheck.c | 2 +- src/vars.c | 2 +- src/xprt_handshake.c | 2 +- 43 files changed, 81 insertions(+), 86 deletions(-) diff --git a/addons/promex/service-prometheus.c b/addons/promex/service-prometheus.c index 33e6f5a73..74310a366 100644 --- a/addons/promex/service-prometheus.c +++ b/addons/promex/service-prometheus.c @@ -242,8 +242,8 @@ void promex_register_module(struct promex_module *m) } /* Pools used to allocate ref on Promex modules and filters */ -DECLARE_STATIC_POOL(pool_head_promex_mod_ref, "promex_module_ref", sizeof(struct promex_module_ref)); -DECLARE_STATIC_POOL(pool_head_promex_metric_flt, "promex_metric_filter", sizeof(struct promex_metric_filter)); +DECLARE_STATIC_TYPED_POOL(pool_head_promex_mod_ref, "promex_module_ref", struct promex_module_ref); +DECLARE_STATIC_TYPED_POOL(pool_head_promex_metric_flt, "promex_metric_filter", struct promex_metric_filter); /* Return the server status. */ enum promex_srv_state promex_srv_status(struct server *sv) diff --git a/src/applet.c b/src/applet.c index 6bfff12de..584d2b9f0 100644 --- a/src/applet.c +++ b/src/applet.c @@ -29,7 +29,7 @@ unsigned int nb_applets = 0; -DECLARE_POOL(pool_head_appctx, "appctx", sizeof(struct appctx)); +DECLARE_TYPED_POOL(pool_head_appctx, "appctx", struct appctx); /* trace source and events */ diff --git a/src/cache.c b/src/cache.c index 1b3c2dcff..7e86e6b96 100644 --- a/src/cache.c +++ b/src/cache.c @@ -229,7 +229,7 @@ static struct list caches = LIST_HEAD_INIT(caches); static struct list caches_config = LIST_HEAD_INIT(caches_config); /* cache config to init */ static struct cache *tmp_cache_config = NULL; -DECLARE_STATIC_POOL(pool_head_cache_st, "cache_st", sizeof(struct cache_st)); +DECLARE_STATIC_TYPED_POOL(pool_head_cache_st, "cache_st", struct cache_st); static struct eb32_node *insert_entry(struct cache *cache, struct cache_tree *tree, struct cache_entry *new_entry); static void delete_entry(struct cache_entry *del_entry); diff --git a/src/compression.c b/src/compression.c index 1fe5aec3b..ed154b3c8 100644 --- a/src/compression.c +++ b/src/compression.c @@ -156,7 +156,7 @@ int comp_append_algo(struct comp_algo **algos, const char *algo) } #if defined(USE_ZLIB) || defined(USE_SLZ) -DECLARE_STATIC_POOL(pool_comp_ctx, "comp_ctx", sizeof(struct comp_ctx)); +DECLARE_STATIC_TYPED_POOL(pool_comp_ctx, "comp_ctx", struct comp_ctx); /* * Alloc the comp_ctx diff --git a/src/connection.c b/src/connection.c index 458e6b0da..0235e3a2a 100644 --- a/src/connection.c +++ b/src/connection.c @@ -38,11 +38,11 @@ #include -DECLARE_POOL(pool_head_connection, "connection", sizeof(struct connection)); -DECLARE_POOL(pool_head_conn_hash_node, "conn_hash_node", sizeof(struct conn_hash_node)); -DECLARE_POOL(pool_head_sockaddr, "sockaddr", sizeof(struct sockaddr_storage)); -DECLARE_POOL(pool_head_pp_tlv_128, "pp_tlv_128", sizeof(struct conn_tlv_list) + HA_PP2_TLV_VALUE_128); -DECLARE_POOL(pool_head_pp_tlv_256, "pp_tlv_256", sizeof(struct conn_tlv_list) + HA_PP2_TLV_VALUE_256); +DECLARE_TYPED_POOL(pool_head_connection, "connection", struct connection); +DECLARE_TYPED_POOL(pool_head_conn_hash_node, "conn_hash_node", struct conn_hash_node); +DECLARE_TYPED_POOL(pool_head_sockaddr, "sockaddr", struct sockaddr_storage); +DECLARE_TYPED_POOL(pool_head_pp_tlv_128, "pp_tlv_128", struct conn_tlv_list, HA_PP2_TLV_VALUE_128); +DECLARE_TYPED_POOL(pool_head_pp_tlv_256, "pp_tlv_256", struct conn_tlv_list, HA_PP2_TLV_VALUE_256); struct idle_conns idle_conns[MAX_THREADS] = { }; struct xprt_ops *registered_xprt[XPRT_ENTRIES] = { NULL, }; diff --git a/src/dns.c b/src/dns.c index 16b3ef76e..054f90a0c 100644 --- a/src/dns.c +++ b/src/dns.c @@ -39,8 +39,8 @@ static THREAD_LOCAL char *dns_msg_trash; -DECLARE_STATIC_POOL(dns_session_pool, "dns_session", sizeof(struct dns_session)); -DECLARE_STATIC_POOL(dns_query_pool, "dns_query", sizeof(struct dns_query)); +DECLARE_STATIC_TYPED_POOL(dns_session_pool, "dns_session", struct dns_session); +DECLARE_STATIC_TYPED_POOL(dns_query_pool, "dns_query", struct dns_query); DECLARE_STATIC_POOL(dns_msg_buf, "dns_msg_buf", DNS_TCP_MSG_RING_MAX_SIZE); /* Opens an UDP socket on the namesaver's IP/Port, if required. Returns 0 on diff --git a/src/event_hdl.c b/src/event_hdl.c index 51553b082..1929f00f7 100644 --- a/src/event_hdl.c +++ b/src/event_hdl.c @@ -58,10 +58,10 @@ struct event_hdl_async_task_default_ctx }; /* memory pools declarations */ -DECLARE_STATIC_POOL(pool_head_sub, "ehdl_sub", sizeof(struct event_hdl_sub)); -DECLARE_STATIC_POOL(pool_head_sub_event, "ehdl_sub_e", sizeof(struct event_hdl_async_event)); -DECLARE_STATIC_POOL(pool_head_sub_event_data, "ehdl_sub_ed", sizeof(struct event_hdl_async_event_data)); -DECLARE_STATIC_POOL(pool_head_sub_taskctx, "ehdl_sub_tctx", sizeof(struct event_hdl_async_task_default_ctx)); +DECLARE_STATIC_TYPED_POOL(pool_head_sub, "ehdl_sub", struct event_hdl_sub); +DECLARE_STATIC_TYPED_POOL(pool_head_sub_event, "ehdl_sub_e", struct event_hdl_async_event); +DECLARE_STATIC_TYPED_POOL(pool_head_sub_event_data, "ehdl_sub_ed", struct event_hdl_async_event_data); +DECLARE_STATIC_TYPED_POOL(pool_head_sub_taskctx, "ehdl_sub_tctx", struct event_hdl_async_task_default_ctx); /* global event_hdl tunables (public variable) */ struct event_hdl_tune event_hdl_tune; diff --git a/src/fcgi-app.c b/src/fcgi-app.c index ae3a79153..1c957a794 100644 --- a/src/fcgi-app.c +++ b/src/fcgi-app.c @@ -35,9 +35,9 @@ static struct fcgi_app *fcgi_apps = NULL; struct flt_ops fcgi_flt_ops; const char *fcgi_flt_id = "FCGI filter"; -DECLARE_STATIC_POOL(pool_head_fcgi_flt_ctx, "fcgi_flt_ctx", sizeof(struct fcgi_flt_ctx)); -DECLARE_STATIC_POOL(pool_head_fcgi_param_rule, "fcgi_param_rule", sizeof(struct fcgi_param_rule)); -DECLARE_STATIC_POOL(pool_head_fcgi_hdr_rule, "fcgi_hdr_rule", sizeof(struct fcgi_hdr_rule)); +DECLARE_STATIC_TYPED_POOL(pool_head_fcgi_flt_ctx, "fcgi_flt_ctx", struct fcgi_flt_ctx); +DECLARE_STATIC_TYPED_POOL(pool_head_fcgi_param_rule, "fcgi_param_rule", struct fcgi_param_rule); +DECLARE_STATIC_TYPED_POOL(pool_head_fcgi_hdr_rule, "fcgi_hdr_rule", struct fcgi_hdr_rule); /**************************************************************************/ /***************************** Uitls **************************************/ diff --git a/src/filters.c b/src/filters.c index 3b0662b3c..22c09581b 100644 --- a/src/filters.c +++ b/src/filters.c @@ -30,7 +30,7 @@ #define TRACE_SOURCE &trace_strm /* Pool used to allocate filters */ -DECLARE_STATIC_POOL(pool_head_filter, "filter", sizeof(struct filter)); +DECLARE_STATIC_TYPED_POOL(pool_head_filter, "filter", struct filter); static int handle_analyzer_result(struct stream *s, struct channel *chn, unsigned int an_bit, int ret); diff --git a/src/flt_bwlim.c b/src/flt_bwlim.c index 3c75b9bb0..0ca768091 100644 --- a/src/flt_bwlim.c +++ b/src/flt_bwlim.c @@ -65,7 +65,7 @@ struct bwlim_state { /* Pools used to allocate comp_state structs */ -DECLARE_STATIC_POOL(pool_head_bwlim_state, "bwlim_state", sizeof(struct bwlim_state)); +DECLARE_STATIC_TYPED_POOL(pool_head_bwlim_state, "bwlim_state", struct bwlim_state); /* Apply the bandwidth limitation of the filter . is the maximum diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index 9862f7d0d..5a5b65c04 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -42,7 +42,7 @@ struct comp_state { }; /* Pools used to allocate comp_state structs */ -DECLARE_STATIC_POOL(pool_head_comp_state, "comp_state", sizeof(struct comp_state)); +DECLARE_STATIC_TYPED_POOL(pool_head_comp_state, "comp_state", struct comp_state); static THREAD_LOCAL struct buffer tmpbuf; static THREAD_LOCAL struct buffer zbuf; diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 3a42076cf..8eb2681a0 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -245,8 +245,8 @@ int curpxopts; int curpxopts2; /* Pools used to allocate SPOE structs */ -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)); +DECLARE_STATIC_TYPED_POOL(pool_head_spoe_ctx, "spoe_ctx", struct spoe_context); +DECLARE_STATIC_TYPED_POOL(pool_head_spoe_appctx, "spoe_appctx", struct spoe_appctx); struct flt_ops spoe_ops; diff --git a/src/h3.c b/src/h3.c index d88d9bcd2..f071748ee 100644 --- a/src/h3.c +++ b/src/h3.c @@ -148,7 +148,7 @@ struct h3c { struct h3_counters *prx_counters; }; -DECLARE_STATIC_POOL(pool_head_h3c, "h3c", sizeof(struct h3c)); +DECLARE_STATIC_TYPED_POOL(pool_head_h3c, "h3c", struct h3c); #define H3_SF_UNI_INIT 0x00000001 /* stream type not parsed for unidirectional stream */ #define H3_SF_UNI_NO_H3 0x00000002 /* unidirectional stream does not carry H3 frames */ @@ -171,7 +171,7 @@ struct h3s { int err; /* used for stream reset */ }; -DECLARE_STATIC_POOL(pool_head_h3s, "h3s", sizeof(struct h3s)); +DECLARE_STATIC_TYPED_POOL(pool_head_h3s, "h3s", struct h3s); /* Initialize an uni-stream by reading its type from . * diff --git a/src/hlua.c b/src/hlua.c index 398831a88..5d17685f6 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -456,7 +456,7 @@ struct hlua_cli_ctx { struct hlua_function *fcn; }; -DECLARE_STATIC_POOL(pool_head_hlua_flt_ctx, "hlua_flt_ctx", sizeof(struct hlua_flt_ctx)); +DECLARE_STATIC_TYPED_POOL(pool_head_hlua_flt_ctx, "hlua_flt_ctx", struct hlua_flt_ctx); static int hlua_filter_from_payload(struct filter *filter); @@ -469,7 +469,7 @@ static struct list referenced_filters = LIST_HEAD_INIT(referenced_filters); /* This is the memory pool containing struct lua for applets * (including cli). */ -DECLARE_STATIC_POOL(pool_head_hlua, "hlua", sizeof(struct hlua)); +DECLARE_STATIC_TYPED_POOL(pool_head_hlua, "hlua", struct hlua); /* Used for Socket connection. */ static struct proxy *socket_proxy; @@ -692,7 +692,7 @@ struct hlua_event_sub { /* This is the memory pool containing struct hlua_event_sub * for event subscriptions from lua */ -DECLARE_STATIC_POOL(pool_head_hlua_event_sub, "hlua_esub", sizeof(struct hlua_event_sub)); +DECLARE_STATIC_TYPED_POOL(pool_head_hlua_event_sub, "hlua_esub", struct hlua_event_sub); /* These functions converts types between HAProxy internal args or * sample and LUA types. Another function permits to check if the diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c index 3e1cdef69..6d3716404 100644 --- a/src/hlua_fcn.c +++ b/src/hlua_fcn.c @@ -517,7 +517,7 @@ struct hlua_queue_item { /* This is the memory pool containing struct hlua_queue_item (queue items) */ -DECLARE_STATIC_POOL(pool_head_hlua_queue, "hlua_queue", sizeof(struct hlua_queue_item)); +DECLARE_STATIC_TYPED_POOL(pool_head_hlua_queue, "hlua_queue", struct hlua_queue_item); static struct hlua_queue *hlua_check_queue(lua_State *L, int ud) { diff --git a/src/http_ana.c b/src/http_ana.c index 568739050..ed9b03ec8 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -5294,7 +5294,7 @@ void http_set_term_flags(struct stream *s) } -DECLARE_POOL(pool_head_http_txn, "http_txn", sizeof(struct http_txn)); +DECLARE_TYPED_POOL(pool_head_http_txn, "http_txn", struct http_txn); /* * Local variables: diff --git a/src/lb_fwlc.c b/src/lb_fwlc.c index ba2de9e41..aa9d679e0 100644 --- a/src/lb_fwlc.c +++ b/src/lb_fwlc.c @@ -25,7 +25,7 @@ struct fwlc_tree_elt { unsigned int elements; }; -DECLARE_STATIC_POOL(pool_head_fwlc_elt, "fwlc_tree_elt", sizeof(struct fwlc_tree_elt)); +DECLARE_STATIC_TYPED_POOL(pool_head_fwlc_elt, "fwlc_tree_elt", struct fwlc_tree_elt); #define FWLC_LBPRM_SEQ(lbprm) ((lbprm) & 0xffffffff) #define FWLC_LBPRM_SMALLEST(lbprm) ((lbprm) >> 32) diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index 33f7ef0ab..b217ec8f5 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -285,8 +285,8 @@ static struct trace_source trace_fcgi __read_mostly = { INITCALL1(STG_REGISTER, trace_register_source, TRACE_SOURCE); /* FCGI connection and stream pools */ -DECLARE_STATIC_POOL(pool_head_fcgi_conn, "fcgi_conn", sizeof(struct fcgi_conn)); -DECLARE_STATIC_POOL(pool_head_fcgi_strm, "fcgi_strm", sizeof(struct fcgi_strm)); +DECLARE_STATIC_TYPED_POOL(pool_head_fcgi_conn, "fcgi_conn", struct fcgi_conn); +DECLARE_STATIC_TYPED_POOL(pool_head_fcgi_strm, "fcgi_strm", struct fcgi_strm); struct task *fcgi_timeout_task(struct task *t, void *context, unsigned int state); static int fcgi_process(struct fcgi_conn *fconn); diff --git a/src/mux_h1.c b/src/mux_h1.c index bc2e940c1..839c9b9c3 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -333,8 +333,8 @@ INITCALL1(STG_REGISTER, stats_register_module, &h1_stats_module); /* the h1c and h1s pools */ -DECLARE_STATIC_POOL(pool_head_h1c, "h1c", sizeof(struct h1c)); -DECLARE_STATIC_POOL(pool_head_h1s, "h1s", sizeof(struct h1s)); +DECLARE_STATIC_TYPED_POOL(pool_head_h1c, "h1c", struct h1c); +DECLARE_STATIC_TYPED_POOL(pool_head_h1s, "h1s", struct h1s); static int h1_recv(struct h1c *h1c); static int h1_send(struct h1c *h1c); diff --git a/src/mux_h2.c b/src/mux_h2.c index 76bea0a61..f16e93cdb 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -448,10 +448,10 @@ static struct stats_module h2_stats_module = { INITCALL1(STG_REGISTER, stats_register_module, &h2_stats_module); /* the h2c connection pool */ -DECLARE_STATIC_POOL(pool_head_h2c, "h2c", sizeof(struct h2c)); +DECLARE_STATIC_TYPED_POOL(pool_head_h2c, "h2c", struct h2c); /* the h2s stream pool */ -DECLARE_STATIC_POOL(pool_head_h2s, "h2s", sizeof(struct h2s)); +DECLARE_STATIC_TYPED_POOL(pool_head_h2s, "h2s", struct h2s); /* the shared rx_bufs pool */ struct pool_head *pool_head_h2_rx_bufs __read_mostly = NULL; diff --git a/src/mux_pt.c b/src/mux_pt.c index 31469c7d8..2c96a2f80 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -27,7 +27,7 @@ struct mux_pt_ctx { struct wait_event wait_event; }; -DECLARE_STATIC_POOL(pool_head_pt_ctx, "mux_pt", sizeof(struct mux_pt_ctx)); +DECLARE_STATIC_TYPED_POOL(pool_head_pt_ctx, "mux_pt", struct mux_pt_ctx); /* trace source and events */ static void pt_trace(enum trace_level level, uint64_t mask, diff --git a/src/mux_quic.c b/src/mux_quic.c index 65ee6ae44..cdd2cb601 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -33,9 +33,9 @@ #include #include -DECLARE_POOL(pool_head_qcc, "qcc", sizeof(struct qcc)); -DECLARE_POOL(pool_head_qcs, "qcs", sizeof(struct qcs)); -DECLARE_STATIC_POOL(pool_head_qc_stream_rxbuf, "qc_stream_rxbuf", sizeof(struct qc_stream_rxbuf)); +DECLARE_TYPED_POOL(pool_head_qcc, "qcc", struct qcc); +DECLARE_TYPED_POOL(pool_head_qcs, "qcs", struct qcs); +DECLARE_STATIC_TYPED_POOL(pool_head_qc_stream_rxbuf, "qc_stream_rxbuf", struct qc_stream_rxbuf); static void qmux_ctrl_send(struct qc_stream_desc *, uint64_t data, uint64_t offset); static void qmux_ctrl_room(struct qc_stream_desc *, uint64_t room); diff --git a/src/mux_spop.c b/src/mux_spop.c index 4e376b66d..020d121d5 100644 --- a/src/mux_spop.c +++ b/src/mux_spop.c @@ -210,8 +210,8 @@ static struct trace_source trace_spop __read_mostly = { INITCALL1(STG_REGISTER, trace_register_source, TRACE_SOURCE); /* SPOP connection and stream pools */ -DECLARE_STATIC_POOL(pool_head_spop_conn, "spop_conn", sizeof(struct spop_conn)); -DECLARE_STATIC_POOL(pool_head_spop_strm, "spop_strm", sizeof(struct spop_strm)); +DECLARE_STATIC_TYPED_POOL(pool_head_spop_conn, "spop_conn", struct spop_conn); +DECLARE_STATIC_TYPED_POOL(pool_head_spop_strm, "spop_strm", struct spop_strm); const struct ist spop_err_reasons[SPOP_ERR_ENTRIES] = { diff --git a/src/pipe.c b/src/pipe.c index 5599fe018..794b881ec 100644 --- a/src/pipe.c +++ b/src/pipe.c @@ -20,7 +20,7 @@ #include -DECLARE_STATIC_POOL(pool_head_pipe, "pipe", sizeof(struct pipe)); +DECLARE_STATIC_TYPED_POOL(pool_head_pipe, "pipe", struct pipe); struct pipe *pipes_live = NULL; /* pipes which are still ready to use */ diff --git a/src/queue.c b/src/queue.c index 28a2e2dfe..f2afd713d 100644 --- a/src/queue.c +++ b/src/queue.c @@ -92,7 +92,7 @@ s * queue's lock. #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)) -DECLARE_POOL(pool_head_pendconn, "pendconn", sizeof(struct pendconn)); +DECLARE_TYPED_POOL(pool_head_pendconn, "pendconn", 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/quic_ack.c b/src/quic_ack.c index d28a6985c..9a34c1b77 100644 --- a/src/quic_ack.c +++ b/src/quic_ack.c @@ -7,7 +7,7 @@ #include #include -DECLARE_STATIC_POOL(pool_head_quic_arng, "quic_arng", sizeof(struct quic_arng_node)); +DECLARE_STATIC_TYPED_POOL(pool_head_quic_arng, "quic_arng", struct quic_arng_node); /* Deallocate list of ACK ranges. */ void quic_free_arngs(struct quic_conn *qc, struct quic_arngs *arngs) diff --git a/src/quic_conn.c b/src/quic_conn.c index 340b85a1a..0e377bc5c 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -138,11 +138,10 @@ const struct quic_version *preferred_version; */ const struct quic_version quic_version_VN_reserved = { .num = 0, }; -DECLARE_STATIC_POOL(pool_head_quic_conn, "quic_conn", sizeof(struct quic_conn)); -DECLARE_STATIC_POOL(pool_head_quic_conn_closed, "quic_conn_closed", sizeof(struct quic_conn_closed)); -DECLARE_STATIC_POOL(pool_head_quic_cids, "quic_cids", sizeof(struct eb_root)); -DECLARE_POOL(pool_head_quic_connection_id, - "quic_connection_id", sizeof(struct quic_connection_id)); +DECLARE_STATIC_TYPED_POOL(pool_head_quic_conn, "quic_conn", struct quic_conn); +DECLARE_STATIC_TYPED_POOL(pool_head_quic_conn_closed, "quic_conn_closed", struct quic_conn_closed); +DECLARE_STATIC_TYPED_POOL(pool_head_quic_cids, "quic_cids", struct eb_root); +DECLARE_TYPED_POOL(pool_head_quic_connection_id, "quic_connection_id", struct quic_connection_id); struct task *quic_conn_app_io_cb(struct task *t, void *context, unsigned int state); static int quic_conn_init_timer(struct quic_conn *qc); diff --git a/src/quic_frame.c b/src/quic_frame.c index 7e1dbba54..209f03e8b 100644 --- a/src/quic_frame.c +++ b/src/quic_frame.c @@ -22,8 +22,8 @@ #include #include -DECLARE_POOL(pool_head_quic_frame, "quic_frame", sizeof(struct quic_frame)); -DECLARE_POOL(pool_head_qf_crypto, "qf_crypto", sizeof(struct qf_crypto)); +DECLARE_TYPED_POOL(pool_head_quic_frame, "quic_frame", struct quic_frame); +DECLARE_TYPED_POOL(pool_head_qf_crypto, "qf_crypto", struct qf_crypto); const char *quic_frame_type_string(enum quic_frame_type ft) { diff --git a/src/quic_rx.c b/src/quic_rx.c index 9fe7b465f..6932f604b 100644 --- a/src/quic_rx.c +++ b/src/quic_rx.c @@ -36,8 +36,8 @@ #include DECLARE_POOL(pool_head_quic_conn_rxbuf, "quic_conn_rxbuf", QUIC_CONN_RX_BUFSZ); -DECLARE_POOL(pool_head_quic_dgram, "quic_dgram", sizeof(struct quic_dgram)); -DECLARE_POOL(pool_head_quic_rx_packet, "quic_rx_packet", sizeof(struct quic_rx_packet)); +DECLARE_TYPED_POOL(pool_head_quic_dgram, "quic_dgram", struct quic_dgram); +DECLARE_TYPED_POOL(pool_head_quic_rx_packet, "quic_rx_packet", struct quic_rx_packet); /* Decode an expected packet number from its truncated value, * depending on the largest received packet number, and diff --git a/src/quic_ssl.c b/src/quic_ssl.c index f39df08d3..1a291a61c 100644 --- a/src/quic_ssl.c +++ b/src/quic_ssl.c @@ -10,7 +10,7 @@ #include #include -DECLARE_POOL(pool_head_quic_ssl_sock_ctx, "quic_ssl_sock_ctx", sizeof(struct ssl_sock_ctx)); +DECLARE_TYPED_POOL(pool_head_quic_ssl_sock_ctx, "quic_ssl_sock_ctx", struct ssl_sock_ctx); const char *quic_ciphers = "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384" ":TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_CCM_SHA256"; #ifdef HAVE_OPENSSL_QUIC diff --git a/src/quic_stream.c b/src/quic_stream.c index 0d3a438ec..364030477 100644 --- a/src/quic_stream.c +++ b/src/quic_stream.c @@ -12,12 +12,9 @@ #include #include -DECLARE_STATIC_POOL(pool_head_quic_stream_desc, "qc_stream_desc", - sizeof(struct qc_stream_desc)); -DECLARE_STATIC_POOL(pool_head_quic_stream_buf, "qc_stream_buf", - sizeof(struct qc_stream_buf)); -DECLARE_STATIC_POOL(pool_head_quic_stream_ack, "qc_stream_ack", - sizeof(struct qc_stream_ack)); +DECLARE_STATIC_TYPED_POOL(pool_head_quic_stream_desc, "qc_stream_desc", struct qc_stream_desc); +DECLARE_STATIC_TYPED_POOL(pool_head_quic_stream_buf, "qc_stream_buf", struct qc_stream_buf); +DECLARE_STATIC_TYPED_POOL(pool_head_quic_stream_ack, "qc_stream_ack", struct qc_stream_ack); static struct pool_head *pool_head_sbuf; diff --git a/src/quic_tls.c b/src/quic_tls.c index 30a323d2e..40213a1bd 100644 --- a/src/quic_tls.c +++ b/src/quic_tls.c @@ -15,15 +15,15 @@ #include -DECLARE_POOL(pool_head_quic_enc_level, "quic_enc_level", sizeof(struct quic_enc_level)); -DECLARE_POOL(pool_head_quic_pktns, "quic_pktns", sizeof(struct quic_pktns)); -DECLARE_POOL(pool_head_quic_tls_ctx, "quic_tls_ctx", sizeof(struct quic_tls_ctx)); +DECLARE_TYPED_POOL(pool_head_quic_enc_level, "quic_enc_level", struct quic_enc_level); +DECLARE_TYPED_POOL(pool_head_quic_pktns, "quic_pktns", struct quic_pktns); +DECLARE_TYPED_POOL(pool_head_quic_tls_ctx, "quic_tls_ctx", struct quic_tls_ctx); DECLARE_POOL(pool_head_quic_tls_secret, "quic_tls_secret", QUIC_TLS_SECRET_LEN); DECLARE_POOL(pool_head_quic_tls_iv, "quic_tls_iv", QUIC_TLS_IV_LEN); DECLARE_POOL(pool_head_quic_tls_key, "quic_tls_key", QUIC_TLS_KEY_LEN); -DECLARE_POOL(pool_head_quic_crypto_buf, "quic_crypto_buf", sizeof(struct quic_crypto_buf)); -DECLARE_STATIC_POOL(pool_head_quic_cstream, "quic_cstream", sizeof(struct quic_cstream)); +DECLARE_TYPED_POOL(pool_head_quic_crypto_buf, "quic_crypto_buf", struct quic_crypto_buf); +DECLARE_STATIC_TYPED_POOL(pool_head_quic_cstream, "quic_cstream", struct quic_cstream); /* Initial salt depending on QUIC version to derive client/server initial secrets. * This one is for draft-29 QUIC version. diff --git a/src/quic_tx.c b/src/quic_tx.c index dc249d349..160341695 100644 --- a/src/quic_tx.c +++ b/src/quic_tx.c @@ -31,7 +31,7 @@ #include #include -DECLARE_POOL(pool_head_quic_tx_packet, "quic_tx_packet", sizeof(struct quic_tx_packet)); +DECLARE_TYPED_POOL(pool_head_quic_tx_packet, "quic_tx_packet", struct quic_tx_packet); DECLARE_POOL(pool_head_quic_cc_buf, "quic_cc_buf", QUIC_MAX_CC_BUFSIZE); static struct quic_tx_packet *qc_build_pkt(unsigned char **pos, const unsigned char *buf_end, diff --git a/src/resolvers.c b/src/resolvers.c index c788cd437..6daee3e14 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -64,9 +64,9 @@ static THREAD_LOCAL unsigned int recurse = 0; /* counter to track calls to publi static THREAD_LOCAL uint64_t resolv_query_id_seed = 0; /* random seed */ struct resolvers *curr_resolvers = NULL; -DECLARE_STATIC_POOL(resolv_answer_item_pool, "resolv_answer_item", sizeof(struct resolv_answer_item)); -DECLARE_STATIC_POOL(resolv_resolution_pool, "resolv_resolution", sizeof(struct resolv_resolution)); -DECLARE_POOL(resolv_requester_pool, "resolv_requester", sizeof(struct resolv_requester)); +DECLARE_STATIC_TYPED_POOL(resolv_answer_item_pool, "resolv_answer_item", struct resolv_answer_item); +DECLARE_STATIC_TYPED_POOL(resolv_resolution_pool, "resolv_resolution", struct resolv_resolution); +DECLARE_TYPED_POOL(resolv_requester_pool, "resolv_requester", struct resolv_requester); static unsigned int resolution_uuid = 1; unsigned int resolv_failed_resolutions = 0; diff --git a/src/session.c b/src/session.c index 21aff4ed8..c734d721c 100644 --- a/src/session.c +++ b/src/session.c @@ -28,9 +28,8 @@ #include -DECLARE_POOL(pool_head_session, "session", sizeof(struct session)); -DECLARE_POOL(pool_head_sess_priv_conns, "session priv conns list", - sizeof(struct sess_priv_conns)); +DECLARE_TYPED_POOL(pool_head_session, "session", struct session); +DECLARE_TYPED_POOL(pool_head_sess_priv_conns, "session priv conns list", struct sess_priv_conns); int conn_complete_session(struct connection *conn); diff --git a/src/signal.c b/src/signal.c index e5ca614e0..988c328cd 100644 --- a/src/signal.c +++ b/src/signal.c @@ -30,7 +30,7 @@ struct signal_descriptor signal_state[MAX_SIGNAL]; sigset_t blocked_sig; int signal_pending = 0; /* non-zero if t least one signal remains unprocessed */ -DECLARE_STATIC_POOL(pool_head_sig_handlers, "sig_handlers", sizeof(struct sig_handler)); +DECLARE_STATIC_TYPED_POOL(pool_head_sig_handlers, "sig_handlers", 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 diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 1fad578c8..e06239efb 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -155,7 +155,7 @@ struct global_ssl global_ssl = { static BIO_METHOD *ha_meth; -DECLARE_STATIC_POOL(ssl_sock_ctx_pool, "ssl_sock_ctx", sizeof(struct ssl_sock_ctx)); +DECLARE_STATIC_TYPED_POOL(ssl_sock_ctx_pool, "ssl_sock_ctx", struct ssl_sock_ctx); DECLARE_POOL(ssl_sock_client_sni_pool, "ssl_sock_client_sni", TLSEXT_MAXLEN_host_name + 1); diff --git a/src/stconn.c b/src/stconn.c index be6264477..a9ce03d4d 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -24,8 +24,8 @@ #include #include -DECLARE_POOL(pool_head_connstream, "stconn", sizeof(struct stconn)); -DECLARE_POOL(pool_head_sedesc, "sedesc", sizeof(struct sedesc)); +DECLARE_TYPED_POOL(pool_head_connstream, "stconn", struct stconn); +DECLARE_TYPED_POOL(pool_head_sedesc, "sedesc", struct sedesc); /* functions used by default on a detached stream connector */ static void sc_app_abort(struct stconn *sc); diff --git a/src/stream.c b/src/stream.c index 06d1cd86e..b94e682dc 100644 --- a/src/stream.c +++ b/src/stream.c @@ -62,7 +62,7 @@ #include -DECLARE_POOL(pool_head_stream, "stream", sizeof(struct stream)); +DECLARE_TYPED_POOL(pool_head_stream, "stream", struct stream); DECLARE_POOL(pool_head_uniqueid, "uniqueid", UNIQUEID_LEN); /* incremented by each "show sess" to fix a delimiter between streams */ diff --git a/src/task.c b/src/task.c index d2c8f9b58..f60ee99bf 100644 --- a/src/task.c +++ b/src/task.c @@ -27,13 +27,13 @@ extern struct task *process_stream(struct task *t, void *context, unsigned int state); extern void stream_update_timings(struct task *t, uint64_t lat, uint64_t cpu); -DECLARE_POOL(pool_head_task, "task", sizeof(struct task)); -DECLARE_POOL(pool_head_tasklet, "tasklet", sizeof(struct tasklet)); +DECLARE_TYPED_POOL(pool_head_task, "task", struct task); +DECLARE_TYPED_POOL(pool_head_tasklet, "tasklet", struct tasklet); /* This is the memory pool containing all the signal structs. These * struct are used to store each required signal between two tasks. */ -DECLARE_POOL(pool_head_notification, "notification", sizeof(struct notification)); +DECLARE_TYPED_POOL(pool_head_notification, "notification", struct notification); /* The lock protecting all wait queues at once. For now we have no better * alternative since a task may have to be removed from a queue and placed diff --git a/src/tcpcheck.c b/src/tcpcheck.c index 9342f30d2..71712ac9d 100644 --- a/src/tcpcheck.c +++ b/src/tcpcheck.c @@ -72,7 +72,7 @@ struct eb_root shared_tcpchecks = EB_ROOT; -DECLARE_POOL(pool_head_tcpcheck_rule, "tcpcheck_rule", sizeof(struct tcpcheck_rule)); +DECLARE_TYPED_POOL(pool_head_tcpcheck_rule, "tcpcheck_rule", struct tcpcheck_rule); /**************************************************************************/ /*************** Init/deinit tcp-check rules and ruleset ******************/ diff --git a/src/vars.c b/src/vars.c index 7c4bdd4ba..5cef93586 100644 --- a/src/vars.c +++ b/src/vars.c @@ -24,7 +24,7 @@ /* This contains a pool of struct vars */ -DECLARE_STATIC_POOL(var_pool, "vars", sizeof(struct var)); +DECLARE_STATIC_TYPED_POOL(var_pool, "vars", struct var); /* list of variables for the process scope. */ struct vars proc_vars THREAD_ALIGNED(64); diff --git a/src/xprt_handshake.c b/src/xprt_handshake.c index 4d6b4bb89..9e7bdccca 100644 --- a/src/xprt_handshake.c +++ b/src/xprt_handshake.c @@ -20,7 +20,7 @@ struct xprt_handshake_ctx { void *xprt_ctx; }; -DECLARE_STATIC_POOL(xprt_handshake_ctx_pool, "xprt_handshake_ctx", sizeof(struct xprt_handshake_ctx)); +DECLARE_STATIC_TYPED_POOL(xprt_handshake_ctx_pool, "xprt_handshake_ctx", struct xprt_handshake_ctx); /* This XPRT doesn't take care of sending or receiving data, once its handshake * is done, it just removes itself