Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > f2c9a24e570f82c24fd7074143d03478 > files > 15

nss_ldap-253-42.el5.src.rpm

diff -uNr nss_ldap-255/configure.in nss_ldap-256/configure.in
--- nss_ldap-255/configure.in	2007-03-03 02:12:37.000000000 -0500
+++ nss_ldap-256/configure.in	2007-06-19 11:08:41.000000000 -0400
@@ -194,7 +194,9 @@
 AC_CHECK_FUNCS(snprintf)
 AC_CHECK_FUNCS(gethostbyname)
 AC_CHECK_FUNCS(nsdispatch)
+AC_CHECK_LIB(pthread_nonshared, main)
 AC_CHECK_FUNCS(pthread_atfork)
+AC_CHECK_FUNCS(pthread_once)
 AC_CHECK_FUNCS(ether_aton)
 AC_CHECK_FUNCS(ether_ntoa)
 
diff -uNr nss_ldap-255/ldap-nss.c nss_ldap-256/ldap-nss.c
--- nss_ldap-255/ldap-nss.c	2007-03-03 02:12:37.000000000 -0500
+++ nss_ldap-256/ldap-nss.c	2007-06-19 11:08:41.000000000 -0400
@@ -1120,6 +1120,11 @@
    * threading library, and we need to compare the current
    * process ID against the saved one to figure out
    * whether we've forked. 
+   *
+   * --
+   *  __pthread_once does not imply __pthread_atfork being non-NULL!
+   *  <tjanouse@redhat.com>
+   * --
    * 
    * Once we know whether we have forked or not, 
    * courtesy of pthread_atfork() or us checking
@@ -1131,7 +1136,7 @@
    * will wreak all sorts of havoc or inefficiencies,
    * respectively.
    */
-  if (__pthread_once == NULL)
+  if (__pthread_once == NULL || __pthread_atfork == NULL)
     pid = getpid ();
   else
     pid = -1;			/* linked against libpthreads, don't care */
@@ -1150,11 +1155,11 @@
 #elif defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
   syslog (LOG_DEBUG,
 	  "nss_ldap: libpthreads=%s, __session.ls_state=%d, __session.ls_conn=%p, __pid=%i, pid=%i, __euid=%i, euid=%i",
-	  (__pthread_once == NULL ? "FALSE" : "TRUE"),
+ 	  ((__pthread_once == NULL || __pthread_atfork == NULL) ? "FALSE" : "TRUE"),
 	  __session.ls_state,
 	  __session.ls_conn,
-	  (__pthread_once == NULL ? __pid : -1),
-	  (__pthread_once == NULL ? pid : -1), __euid, euid);
+ 	  ((__pthread_once == NULL || __pthread_atfork == NULL) ? __pid : -1),
+ 	  ((__pthread_once == NULL || __pthread_atfork == NULL) ? pid : -1), __euid, euid);
 #else
   syslog (LOG_DEBUG,
 	  "nss_ldap: __session.ls_state=%d, __session.ls_conn=%p, __pid=%i, pid=%i, __euid=%i, euid=%i",
@@ -1172,7 +1177,7 @@
   else
 #ifndef HAVE_PTHREAD_ATFORK
 #if defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
-  if (__pthread_once == NULL && __pid != pid)
+  if ((__pthread_once == NULL || __pthread_atfork == NULL) && __pid != pid)
 #else
   if (__pid != pid)
 #endif /* HAVE_LIBC_LOCK_H || HAVE_BITS_LIBC_LOCK_H */
@@ -1230,19 +1235,21 @@
   __session.ls_timestamp = 0;
   __session.ls_state = LS_UNINITIALIZED;
 
-#ifdef HAVE_PTHREAD_ATFORK
+#if defined(HAVE_PTHREAD_ONCE) && defined(HAVE_PTHREAD_ATFORK)
   if (pthread_once (&__once, do_atfork_setup) != 0)
     {
       debug ("<== do_init (pthread_once failed)");
       return NSS_UNAVAIL;
     }
+#elif defined(HAVE_PTHREAD_ATFORK) && ( defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H) )
+  __libc_once (__once, do_atfork_setup);
 #elif defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
   /*
    * Only install the pthread_atfork() handlers i
    * we are linked against libpthreads. Otherwise,
    * do close the session when the PID changes.
    */
-  if (__pthread_once == NULL)
+  if (__pthread_once == NULL || __pthread_atfork == NULL)
     __pid = pid;
   else
     __libc_once (__once, do_atfork_setup);