2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Use library constructor/destructor to initialize OpenSSL

Instead of calling isc_tls_initialize()/isc_tls_destroy() explicitly use
gcc/clang attributes on POSIX and DLLMain on Windows to initialize and
shutdown OpenSSL library.

This resolves the issue when isc_nm_create() / isc_nm_destroy() was
called multiple times and it would call OpenSSL library destructors from
isc_nm_destroy().

At the same time, since we now have introduced the ctor/dtor for libisc,
this commit moves the isc_mem API initialization (the list of the
contexts) and changes the isc_mem_checkdestroyed() to schedule the
checking of memory context on library unload instead of executing the
code immediately.
This commit is contained in:
Ondřej Surý
2021-02-09 17:44:40 +01:00
parent 4bde4f050b
commit 494d0da522
15 changed files with 165 additions and 87 deletions

View File

@@ -216,8 +216,6 @@ isc_nm_start(isc_mem_t *mctx, uint32_t workers) {
isc__nm_winsock_initialize();
#endif /* WIN32 */
isc_tls_initialize();
mgr = isc_mem_get(mctx, sizeof(*mgr));
*mgr = (isc_nm_t){ .nworkers = workers };
@@ -374,8 +372,6 @@ nm_destroy(isc_nm_t **mgr0) {
mgr->nworkers * sizeof(isc__networker_t));
isc_mem_putanddetach(&mgr->mctx, mgr, sizeof(*mgr));
isc_tls_destroy();
#ifdef WIN32
isc__nm_winsock_destroy();
#endif /* WIN32 */