]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: xprt: use an initcall to register the transport layers
authorWilly Tarreau <w@1wt.eu>
Mon, 25 Apr 2022 17:18:24 +0000 (19:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Apr 2022 17:18:24 +0000 (19:18 +0200)
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.

src/raw_sock.c
src/ssl_sock.c
src/xprt_handshake.c
src/xprt_quic.c

index a6773e7909fd34b814e5153e76da5e1d8711c0f3..cc72e6023fafa6e0a2574c0f48cf3ea5d620e5c8 100644 (file)
@@ -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
index d823d92d3caba37bfd689f6f054e6da1c64aacda..fd2aff92a6baba7a96589f7fa41a54044f6f90ce 100644 (file)
@@ -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);
 
 
 /*
index 75ebdae762a4aa98c2f49fcac77ba045dc90964a..7b2265f5ab24755a32fcb4d656f82046b9693946 100644 (file)
@@ -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);
index 7f331d1692b0e0b672a2e553486f388fe2bc8bd8..0b2c59c6fcc0ced094de034097031f1560bd66fc 100644 (file)
@@ -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 <buf> from QUIC connection with <owner>
  * as owner calling <func> function.