mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 22:31:06 +01:00
MINOR: initcall: use initcalls for section parsers
The two calls to cfg_register_section() and cfg_register_postparser() are now supported by initcalls. This allowed to remove two other constructors.
This commit is contained in:
parent
172f5ce948
commit
e655251e80
@ -24,6 +24,7 @@
|
||||
|
||||
#include <common/compat.h>
|
||||
#include <common/config.h>
|
||||
#include <common/initcall.h>
|
||||
#include <common/mini-clist.h>
|
||||
|
||||
#include <proto/log.h>
|
||||
@ -143,6 +144,13 @@ static inline int warnifnotcap(struct proxy *proxy, int cap, const char *file, i
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* simplified way to define a section parser */
|
||||
#define REGISTER_CONFIG_SECTION(name, parse, post) \
|
||||
INITCALL3(STG_REGISTER, cfg_register_section, (name), (parse), (post))
|
||||
|
||||
#define REGISTER_CONFIG_POSTPARSER(name, parser) \
|
||||
INITCALL2(STG_REGISTER, cfg_register_postparser, (name), (parser))
|
||||
|
||||
#endif /* _COMMON_CFGPARSE_H */
|
||||
|
||||
/*
|
||||
|
||||
@ -1215,7 +1215,9 @@ struct applet http_cache_applet = {
|
||||
__attribute__((constructor))
|
||||
static void __cache_init(void)
|
||||
{
|
||||
cfg_register_section("cache", cfg_parse_cache, cfg_post_parse_section_cache);
|
||||
cfg_register_postparser("cache", cfg_cache_postparser);
|
||||
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);
|
||||
|
||||
@ -3851,21 +3851,17 @@ void cfg_restore_sections(struct list *backup_sections)
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((constructor))
|
||||
static void cfgparse_init(void)
|
||||
{
|
||||
/* Register internal sections */
|
||||
cfg_register_section("listen", cfg_parse_listen, NULL);
|
||||
cfg_register_section("frontend", cfg_parse_listen, NULL);
|
||||
cfg_register_section("backend", cfg_parse_listen, NULL);
|
||||
cfg_register_section("defaults", cfg_parse_listen, NULL);
|
||||
cfg_register_section("global", cfg_parse_global, NULL);
|
||||
cfg_register_section("userlist", cfg_parse_users, NULL);
|
||||
cfg_register_section("peers", cfg_parse_peers, NULL);
|
||||
cfg_register_section("mailers", cfg_parse_mailers, NULL);
|
||||
cfg_register_section("namespace_list", cfg_parse_netns, NULL);
|
||||
cfg_register_section("resolvers", cfg_parse_resolvers, NULL);
|
||||
}
|
||||
/* these are the config sections handled by default */
|
||||
REGISTER_CONFIG_SECTION("listen", cfg_parse_listen, NULL);
|
||||
REGISTER_CONFIG_SECTION("frontend", cfg_parse_listen, NULL);
|
||||
REGISTER_CONFIG_SECTION("backend", cfg_parse_listen, NULL);
|
||||
REGISTER_CONFIG_SECTION("defaults", cfg_parse_listen, NULL);
|
||||
REGISTER_CONFIG_SECTION("global", cfg_parse_global, NULL);
|
||||
REGISTER_CONFIG_SECTION("userlist", cfg_parse_users, NULL);
|
||||
REGISTER_CONFIG_SECTION("peers", cfg_parse_peers, NULL);
|
||||
REGISTER_CONFIG_SECTION("mailers", cfg_parse_mailers, NULL);
|
||||
REGISTER_CONFIG_SECTION("namespace_list", cfg_parse_netns, NULL);
|
||||
REGISTER_CONFIG_SECTION("resolvers", cfg_parse_resolvers, NULL);
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
|
||||
@ -2058,8 +2058,7 @@ 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);
|
||||
|
||||
cfg_register_postparser("dns runtime resolver", dns_finalize_config);
|
||||
}
|
||||
|
||||
REGISTER_POST_DEINIT(dns_deinit);
|
||||
REGISTER_CONFIG_POSTPARSER("dns runtime resolver", dns_finalize_config);
|
||||
|
||||
@ -8207,12 +8207,6 @@ void hlua_init(void)
|
||||
RESET_SAFE_LJMP(gL.T);
|
||||
}
|
||||
|
||||
__attribute__((constructor))
|
||||
static void __hlua_init(void)
|
||||
{
|
||||
cfg_register_postparser("hlua", hlua_check_config);
|
||||
}
|
||||
|
||||
static void hlua_register_build_options(void)
|
||||
{
|
||||
char *ptr = NULL;
|
||||
@ -8222,3 +8216,4 @@ static void hlua_register_build_options(void)
|
||||
}
|
||||
|
||||
INITCALL0(STG_REGISTER, hlua_register_build_options);
|
||||
REGISTER_CONFIG_POSTPARSER("hlua", hlua_check_config);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user