MINOR: initcall: apply initcall to all register_build_opts() calls
Most register_build_opts() calls use static strings. These ones were replaced with a trivial REGISTER_BUILD_OPTS() statement adding the string and its call to the STG_REGISTER section. A dedicated section could be made for this if needed, but there are very few such calls for this to be worth it. The calls made with computed strings however, like those which retrieve OpenSSL's version or zlib's version, were moved to a dedicated function to guarantee they are called late in the process. For example, the SSL call probably requires that SSL_library_init() has been called first.
This commit is contained in:
parent
86abe44e42
commit
8071338c78
|
@ -25,8 +25,9 @@
|
|||
#include <netinet/in.h>
|
||||
|
||||
#include <common/config.h>
|
||||
#include <common/standard.h>
|
||||
#include <common/initcall.h>
|
||||
#include <common/hathreads.h>
|
||||
#include <common/standard.h>
|
||||
|
||||
#include <types/listener.h>
|
||||
#include <types/proxy.h>
|
||||
|
@ -246,6 +247,10 @@ void hap_register_per_thread_deinit(void (*fct)());
|
|||
|
||||
void mworker_accept_wrapper(int fd);
|
||||
|
||||
/* simplified way to declare static build options in a file */
|
||||
#define REGISTER_BUILD_OPTS(str) \
|
||||
INITCALL2(STG_REGISTER, hap_register_build_opts, (str), 0)
|
||||
|
||||
#endif /* _TYPES_GLOBAL_H */
|
||||
|
||||
/*
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <common/buffer.h>
|
||||
#include <common/errors.h>
|
||||
#include <common/initcall.h>
|
||||
#include <types/global.h>
|
||||
#include <proto/arg.h>
|
||||
#include <proto/http_fetch.h>
|
||||
#include <proto/log.h>
|
||||
|
@ -689,8 +690,8 @@ INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws);
|
|||
__attribute__((constructor))
|
||||
static void __51d_init(void)
|
||||
{
|
||||
/* register sample fetch and conversion keywords */
|
||||
hap_register_build_opts("Built with 51Degrees support.", 0);
|
||||
hap_register_post_check(init_51degrees);
|
||||
hap_register_post_deinit(deinit_51degrees);
|
||||
}
|
||||
|
||||
REGISTER_BUILD_OPTS("Built with 51Degrees support.");
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <common/config.h>
|
||||
#include <common/errors.h>
|
||||
#include <common/hathreads.h>
|
||||
#include <common/initcall.h>
|
||||
|
||||
#include <proto/acl.h>
|
||||
#include <proto/log.h>
|
||||
|
@ -313,8 +314,4 @@ pat_match_auth(struct sample *smp, struct pattern_expr *expr, int fill)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
__attribute__((constructor))
|
||||
static void __auth_init(void)
|
||||
{
|
||||
hap_register_build_opts("Encrypted password support via crypt(3): yes", 0);
|
||||
}
|
||||
REGISTER_BUILD_OPTS("Encrypted password support via crypt(3): yes");
|
||||
|
|
|
@ -705,9 +705,6 @@ INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
|
|||
__attribute__((constructor))
|
||||
static void __comp_fetch_init(void)
|
||||
{
|
||||
char *ptr = NULL;
|
||||
int i;
|
||||
|
||||
#ifdef USE_SLZ
|
||||
slz_make_crc_table();
|
||||
slz_prepare_dist_table();
|
||||
|
@ -720,6 +717,13 @@ static void __comp_fetch_init(void)
|
|||
#if defined(USE_ZLIB) && defined(DEFAULT_MAXZLIBMEM)
|
||||
global.maxzlibmem = DEFAULT_MAXZLIBMEM * 1024U * 1024U;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void comp_register_build_opts(void)
|
||||
{
|
||||
char *ptr = NULL;
|
||||
int i;
|
||||
|
||||
#ifdef USE_ZLIB
|
||||
memprintf(&ptr, "Built with zlib version : " ZLIB_VERSION);
|
||||
memprintf(&ptr, "%s\nRunning on zlib version : %s", ptr, zlibVersion());
|
||||
|
@ -738,3 +742,5 @@ static void __comp_fetch_init(void)
|
|||
|
||||
hap_register_build_opts(ptr, 1);
|
||||
}
|
||||
|
||||
INITCALL0(STG_REGISTER, comp_register_build_opts);
|
||||
|
|
5
src/da.c
5
src/da.c
|
@ -4,6 +4,7 @@
|
|||
#include <common/errors.h>
|
||||
#include <common/http.h>
|
||||
#include <common/initcall.h>
|
||||
#include <types/global.h>
|
||||
#include <proto/arg.h>
|
||||
#include <proto/http_fetch.h>
|
||||
#include <proto/log.h>
|
||||
|
@ -398,8 +399,8 @@ INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws);
|
|||
__attribute__((constructor))
|
||||
static void __da_init(void)
|
||||
{
|
||||
/* register sample fetch and format conversion keywords */
|
||||
hap_register_build_opts("Built with DeviceAtlas support.", 0);
|
||||
hap_register_post_check(init_deviceatlas);
|
||||
hap_register_post_deinit(deinit_deviceatlas);
|
||||
}
|
||||
|
||||
REGISTER_BUILD_OPTS("Built with DeviceAtlas support.");
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <common/cfgparse.h>
|
||||
#include <common/hathreads.h>
|
||||
#include <common/standard.h>
|
||||
#include <types/global.h>
|
||||
#include <proto/fd.h>
|
||||
|
||||
|
||||
|
@ -110,7 +111,6 @@ static void __hathreads_init(void)
|
|||
#if defined(DEBUG_THREAD) || defined(DEBUG_FULL)
|
||||
memset(lock_stats, 0, sizeof(lock_stats));
|
||||
#endif
|
||||
hap_register_build_opts("Built with multi-threading support.", 0);
|
||||
}
|
||||
|
||||
#endif // USE_THREAD
|
||||
|
@ -148,3 +148,5 @@ int parse_nbthread(const char *arg, char **err)
|
|||
#endif
|
||||
return nbthread;
|
||||
}
|
||||
|
||||
REGISTER_BUILD_OPTS("Built with multi-threading support.");
|
||||
|
|
13
src/hlua.c
13
src/hlua.c
|
@ -8210,8 +8210,15 @@ void hlua_init(void)
|
|||
__attribute__((constructor))
|
||||
static void __hlua_init(void)
|
||||
{
|
||||
char *ptr = NULL;
|
||||
memprintf(&ptr, "Built with Lua version : %s", LUA_RELEASE);
|
||||
hap_register_build_opts(ptr, 1);
|
||||
cfg_register_postparser("hlua", hlua_check_config);
|
||||
}
|
||||
|
||||
static void hlua_register_build_options(void)
|
||||
{
|
||||
char *ptr = NULL;
|
||||
|
||||
memprintf(&ptr, "Built with Lua version : %s", LUA_RELEASE);
|
||||
hap_register_build_opts(ptr, 1);
|
||||
}
|
||||
|
||||
INITCALL0(STG_REGISTER, hlua_register_build_options);
|
||||
|
|
|
@ -106,8 +106,4 @@ int my_socketat(const struct netns_entry *ns, int domain, int type, int protocol
|
|||
return sock;
|
||||
}
|
||||
|
||||
__attribute__((constructor))
|
||||
static void __ns_init(void)
|
||||
{
|
||||
hap_register_build_opts("Built with network namespace support.", 0);
|
||||
}
|
||||
REGISTER_BUILD_OPTS("Built with network namespace support.");
|
||||
|
|
|
@ -2032,30 +2032,26 @@ static struct action_kw_list http_res_actions = {ILH, {
|
|||
|
||||
INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_actions);
|
||||
|
||||
__attribute__((constructor))
|
||||
static void __tcp_protocol_init(void)
|
||||
{
|
||||
hap_register_build_opts("Built with transparent proxy support using:"
|
||||
REGISTER_BUILD_OPTS("Built with transparent proxy support using:"
|
||||
#if defined(IP_TRANSPARENT)
|
||||
" IP_TRANSPARENT"
|
||||
" IP_TRANSPARENT"
|
||||
#endif
|
||||
#if defined(IPV6_TRANSPARENT)
|
||||
" IPV6_TRANSPARENT"
|
||||
" IPV6_TRANSPARENT"
|
||||
#endif
|
||||
#if defined(IP_FREEBIND)
|
||||
" IP_FREEBIND"
|
||||
" IP_FREEBIND"
|
||||
#endif
|
||||
#if defined(IP_BINDANY)
|
||||
" IP_BINDANY"
|
||||
" IP_BINDANY"
|
||||
#endif
|
||||
#if defined(IPV6_BINDANY)
|
||||
" IPV6_BINDANY"
|
||||
" IPV6_BINDANY"
|
||||
#endif
|
||||
#if defined(SO_BINDANY)
|
||||
" SO_BINDANY"
|
||||
" SO_BINDANY"
|
||||
#endif
|
||||
"", 0);
|
||||
}
|
||||
"");
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -411,8 +411,7 @@ int regex_comp(const char *str, struct my_regex *regex, int cs, int cap, char **
|
|||
return 1;
|
||||
}
|
||||
|
||||
__attribute__((constructor))
|
||||
static void __regex_init(void)
|
||||
static void regex_register_build_options(void)
|
||||
{
|
||||
char *ptr = NULL;
|
||||
|
||||
|
@ -458,6 +457,8 @@ static void __regex_init(void)
|
|||
hap_register_build_opts(ptr, 1);
|
||||
}
|
||||
|
||||
INITCALL0(STG_REGISTER, regex_register_build_options);
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
|
|
|
@ -9251,9 +9251,6 @@ static void ssl_sock_capture_free_func(void *parent, void *ptr, CRYPTO_EX_DATA *
|
|||
__attribute__((constructor))
|
||||
static void __ssl_sock_init(void)
|
||||
{
|
||||
char *ptr;
|
||||
int i;
|
||||
|
||||
STACK_OF(SSL_COMP)* cm;
|
||||
|
||||
if (global_ssl.listen_default_ciphers)
|
||||
|
@ -9288,7 +9285,26 @@ static void __ssl_sock_init(void)
|
|||
hap_register_post_check(tlskeys_finalize_config);
|
||||
#endif
|
||||
|
||||
ptr = NULL;
|
||||
global.ssl_session_max_cost = SSL_SESSION_MAX_COST;
|
||||
global.ssl_handshake_max_cost = SSL_HANDSHAKE_MAX_COST;
|
||||
|
||||
#ifndef OPENSSL_NO_DH
|
||||
ssl_dh_ptr_index = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
|
||||
hap_register_post_deinit(ssl_free_dh);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
hap_register_post_deinit(ssl_free_engines);
|
||||
#endif
|
||||
/* Load SSL string for the verbose & debug mode. */
|
||||
ERR_load_SSL_strings();
|
||||
}
|
||||
|
||||
/* Compute and register the version string */
|
||||
static void ssl_register_build_options()
|
||||
{
|
||||
char *ptr = NULL;
|
||||
int i;
|
||||
|
||||
memprintf(&ptr, "Built with OpenSSL version : "
|
||||
#ifdef OPENSSL_IS_BORINGSSL
|
||||
"BoringSSL");
|
||||
|
@ -9326,21 +9342,11 @@ static void __ssl_sock_init(void)
|
|||
memprintf(&ptr, "%s %s", ptr, methodVersions[i].name);
|
||||
|
||||
hap_register_build_opts(ptr, 1);
|
||||
|
||||
global.ssl_session_max_cost = SSL_SESSION_MAX_COST;
|
||||
global.ssl_handshake_max_cost = SSL_HANDSHAKE_MAX_COST;
|
||||
|
||||
#ifndef OPENSSL_NO_DH
|
||||
ssl_dh_ptr_index = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
|
||||
hap_register_post_deinit(ssl_free_dh);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
hap_register_post_deinit(ssl_free_engines);
|
||||
#endif
|
||||
/* Load SSL string for the verbose & debug mode. */
|
||||
ERR_load_SSL_strings();
|
||||
}
|
||||
|
||||
INITCALL0(STG_REGISTER, ssl_register_build_options);
|
||||
|
||||
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
void ssl_free_engines(void) {
|
||||
struct ssl_engine_list *wl, *wlb;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <common/buffer.h>
|
||||
#include <common/errors.h>
|
||||
#include <common/initcall.h>
|
||||
#include <types/global.h>
|
||||
#include <proto/arg.h>
|
||||
#include <proto/log.h>
|
||||
#include <proto/proto_http.h>
|
||||
|
@ -693,8 +694,6 @@ INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws);
|
|||
__attribute__((constructor))
|
||||
static void __wurfl_init(void)
|
||||
{
|
||||
/* register sample fetch and format conversion keywords */
|
||||
hap_register_build_opts("Built with WURFL support.", 0);
|
||||
hap_register_post_check(ha_wurfl_init);
|
||||
hap_register_post_deinit(ha_wurfl_deinit);
|
||||
}
|
||||
|
@ -802,3 +801,5 @@ static const char *ha_wurfl_retrieve_header(const char *header_name, const void
|
|||
ha_wurfl_log("WURFL: retrieve header request returns [%s]\n", ((ha_wurfl_header_t *)wh)->header_value);
|
||||
return ((ha_wurfl_header_t *)wh)->header_value;
|
||||
}
|
||||
|
||||
REGISTER_BUILD_OPTS("Built with WURFL support.");
|
||||
|
|
Loading…
Reference in New Issue