Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Jul 2017 17:59:15 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r320895 - head/lib/libc/net
Message-ID:  <201707111759.v6BHxFnH008324@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Tue Jul 11 17:59:15 2017
New Revision: 320895
URL: https://svnweb.freebsd.org/changeset/base/320895

Log:
  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

Modified:
  head/lib/libc/net/nsdispatch.c

Modified: head/lib/libc/net/nsdispatch.c
==============================================================================
--- head/lib/libc/net/nsdispatch.c	Tue Jul 11 16:30:16 2017	(r320894)
+++ head/lib/libc/net/nsdispatch.c	Tue Jul 11 17:59:15 2017	(r320895)
@@ -525,8 +525,8 @@ fin:
 	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);
@@ -560,8 +559,6 @@ nss_atexit(void)
 	if (isthreaded)
 		(void)_pthread_rwlock_unlock(&nss_lock);
 }
-
-
 
 /*
  * Finally, the actual implementation.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707111759.v6BHxFnH008324>