From: Willy Tarreau Date: Mon, 25 Apr 2022 17:18:24 +0000 (+0200) Subject: BUILD: xprt: use an initcall to register the transport layers X-Git-Tag: v2.6-dev8~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79367f9a8d777e1199b7f159527f376832917e28;p=thirdparty%2Fhaproxy.git BUILD: xprt: use an initcall to register the transport layers Transport layers (raw_sock, ssl_sock, xprt_handshake and xprt_quic) were using 4 constructors and 2 destructors. The 4 constructors were replaced with INITCALL and the destructors with REGISTER_POST_DEINIT() so that we do not depend on this anymore. --- diff --git a/src/raw_sock.c b/src/raw_sock.c index a6773e7909..cc72e6023f 100644 --- a/src/raw_sock.c +++ b/src/raw_sock.c @@ -474,12 +474,13 @@ static struct xprt_ops raw_sock = { }; -__attribute__((constructor)) static void __raw_sock_init(void) { xprt_register(XPRT_RAW, &raw_sock); } +INITCALL0(STG_REGISTER, __raw_sock_init); + /* * Local variables: * c-indent-level: 8 diff --git a/src/ssl_sock.c b/src/ssl_sock.c index d823d92d3c..fd2aff92a6 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -7939,7 +7939,6 @@ static void ssl_sock_clt_sni_free_func(void *parent, void *ptr, CRYPTO_EX_DATA * pool_free(ssl_sock_client_sni_pool, ptr); } -__attribute__((constructor)) static void __ssl_sock_init(void) { #if (!defined(OPENSSL_NO_COMP) && !defined(SSL_OP_NO_COMPRESSION)) @@ -8036,6 +8035,7 @@ static void __ssl_sock_init(void) */ hap_register_post_deinit(ssl_sock_unregister_msg_callbacks); } +INITCALL0(STG_REGISTER, __ssl_sock_init); /* Compute and register the version string */ static void ssl_register_build_options() @@ -8135,7 +8135,6 @@ void ssl_free_dh(void) { } #endif -__attribute__((destructor)) static void __ssl_sock_deinit(void) { #if (defined SSL_CTRL_SET_TLSEXT_HOSTNAME && !defined SSL_NO_GENERATE_CERTIFICATES) @@ -8157,6 +8156,7 @@ static void __ssl_sock_deinit(void) #endif BIO_meth_free(ha_meth); } +REGISTER_POST_DEINIT(__ssl_sock_deinit); /* diff --git a/src/xprt_handshake.c b/src/xprt_handshake.c index 75ebdae762..7b2265f5ab 100644 --- a/src/xprt_handshake.c +++ b/src/xprt_handshake.c @@ -291,8 +291,9 @@ struct xprt_ops xprt_handshake = { .name = "HS", }; -__attribute__((constructor)) static void __xprt_handshake_init(void) { xprt_register(XPRT_HANDSHAKE, &xprt_handshake); } + +INITCALL0(STG_REGISTER, __xprt_handshake_init); diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 7f331d1692..0b2c59c6fc 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -5769,18 +5769,18 @@ static struct xprt_ops ssl_quic = { .name = "QUIC", }; -__attribute__((constructor)) static void __quic_conn_init(void) { ha_quic_meth = BIO_meth_new(0x666, "ha QUIC methods"); xprt_register(XPRT_QUIC, &ssl_quic); } +INITCALL0(STG_REGISTER, __quic_conn_init); -__attribute__((destructor)) static void __quic_conn_deinit(void) { BIO_meth_free(ha_quic_meth); } +REGISTER_POST_DEINIT(__quic_conn_deinit); /* Read all the QUIC packets found in from QUIC connection with * as owner calling function.