MEDIUM: init: convert all trivial registration calls to initcalls
This switches explicit calls to various trivial registration methods for
keywords, muxes or protocols from constructors to INITCALL1 at stage
STG_REGISTER. All these calls have in common to consume a single pointer
and return void. Doing this removes 26 constructors. The following calls
were addressed :
- acl_register_keywords
- bind_register_keywords
- cfg_register_keywords
- cli_register_kw
- flt_register_keywords
- http_req_keywords_register
- http_res_keywords_register
- protocol_register
- register_mux_proto
- sample_register_convs
- sample_register_fetches
- srv_register_keywords
- tcp_req_conn_keywords_register
- tcp_req_cont_keywords_register
- tcp_req_sess_keywords_register
- tcp_res_cont_keywords_register
- flt_register_keywords
diff --git a/src/vars.c b/src/vars.c
index 8f757f9..e44a786 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -2,6 +2,7 @@
#include <common/cfgparse.h>
#include <common/http.h>
+#include <common/initcall.h>
#include <common/mini-clist.h>
#include <types/vars.h>
@@ -861,42 +862,56 @@
{ /* END */ },
}};
+INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords);
+
static struct sample_conv_kw_list sample_conv_kws = {ILH, {
{ "set-var", smp_conv_store, ARG1(1,STR), conv_check_var, SMP_T_ANY, SMP_T_ANY },
{ "unset-var", smp_conv_clear, ARG1(1,STR), conv_check_var, SMP_T_ANY, SMP_T_ANY },
{ /* END */ },
}};
+INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws);
+
static struct action_kw_list tcp_req_sess_kws = { { }, {
{ "set-var", parse_store, 1 },
{ "unset-var", parse_store, 1 },
{ /* END */ }
}};
+INITCALL1(STG_REGISTER, tcp_req_sess_keywords_register, &tcp_req_sess_kws);
+
static struct action_kw_list tcp_req_cont_kws = { { }, {
{ "set-var", parse_store, 1 },
{ "unset-var", parse_store, 1 },
{ /* END */ }
}};
+INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &tcp_req_cont_kws);
+
static struct action_kw_list tcp_res_kws = { { }, {
{ "set-var", parse_store, 1 },
{ "unset-var", parse_store, 1 },
{ /* END */ }
}};
+INITCALL1(STG_REGISTER, tcp_res_cont_keywords_register, &tcp_res_kws);
+
static struct action_kw_list http_req_kws = { { }, {
{ "set-var", parse_store, 1 },
{ "unset-var", parse_store, 1 },
{ /* END */ }
}};
+INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_kws);
+
static struct action_kw_list http_res_kws = { { }, {
{ "set-var", parse_store, 1 },
{ "unset-var", parse_store, 1 },
{ /* END */ }
}};
+INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_kws);
+
static struct cfg_kw_list cfg_kws = {{ },{
{ CFG_GLOBAL, "tune.vars.global-max-size", vars_max_size_global },
{ CFG_GLOBAL, "tune.vars.proc-max-size", vars_max_size_proc },
@@ -906,19 +921,12 @@
{ /* END */ }
}};
+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);
- sample_register_fetches(&sample_fetch_keywords);
- sample_register_convs(&sample_conv_kws);
- tcp_req_sess_keywords_register(&tcp_req_sess_kws);
- tcp_req_cont_keywords_register(&tcp_req_cont_kws);
- tcp_res_cont_keywords_register(&tcp_res_kws);
- http_req_keywords_register(&http_req_kws);
- http_res_keywords_register(&http_res_kws);
- cfg_register_keywords(&cfg_kws);
-
HA_RWLOCK_INIT(&var_names_rwlock);
}