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.
This commit is contained in:
Willy Tarreau 2022-04-25 19:18:24 +02:00
parent 740d749d77
commit 79367f9a8d
4 changed files with 8 additions and 6 deletions

View 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

View 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);
/*

View 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);

View 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.