Don't dlclose NSS modules from nss_atexit().

As hinted in the commit log message for r259042, this is unnecessary.
Moreover, as a result of that change we may invoke a DSO's atexit handler
after it has been unmapped.

Reviewed by:	bdrewery, cem
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
This commit is contained in:
markj 2017-07-11 17:59:15 +00:00
parent f68f01fa5f
commit ad7b733525

View File

@ -525,7 +525,7 @@ nss_load_module(const char *source, nss_module_register_fn reg_fn)
vector_sort(_nsmod, _nsmodsize, sizeof(*_nsmod), string_compare);
}
static int exiting = 0;
static void
ns_mod_free(ns_mod *mod)
@ -536,12 +536,10 @@ ns_mod_free(ns_mod *mod)
return;
if (mod->unregister != NULL)
mod->unregister(mod->mtab, mod->mtabsize);
if (mod->handle != nss_builtin_handle)
if (mod->handle != nss_builtin_handle && !exiting)
(void)dlclose(mod->handle);
}
/*
* Cleanup
*/
@ -550,6 +548,7 @@ nss_atexit(void)
{
int isthreaded;
exiting = 1;
isthreaded = __isthreaded;
if (isthreaded)
(void)_pthread_rwlock_wrlock(&nss_lock);
@ -561,8 +560,6 @@ nss_atexit(void)
(void)_pthread_rwlock_unlock(&nss_lock);
}
/*
* Finally, the actual implementation.
*/