equal
deleted
inserted
replaced
|
1 Fixes a race condition that can be triggered when multiple threads |
|
2 enter the function ldap_int_utils_init about the same time. |
|
3 Patch was developed in-house; it is Solaris specific and |
|
4 will not be contributed upstream. |
|
5 |
|
6 --- openldap-2.4.44/libraries/libldap/util-int.c.old 2016-06-28 12:13:02.410770969 -0700 |
|
7 +++ openldap-2.4.44/libraries/libldap/util-int.c 2016-06-28 12:13:07.923164035 -0700 |
|
8 @@ -92,6 +92,10 @@ |
|
9 /* Don't know how to handle this version, pretend it's not there */ |
|
10 # undef HAVE_GETHOSTBYADDR_R |
|
11 # endif |
|
12 + |
|
13 +/* use static mutex to protect mutex initialization */ |
|
14 +static ldap_pvt_thread_mutex_t ldap_int_utils_init_mutex = PTHREAD_MUTEX_INITIALIZER; |
|
15 + |
|
16 #endif /* LDAP_R_COMPILE */ |
|
17 |
|
18 char *ldap_pvt_ctime( const time_t *tp, char *buf ) |
|
19 @@ -700,9 +704,17 @@ |
|
20 static int done=0; |
|
21 if (done) |
|
22 return; |
|
23 +#ifndef LDAP_R_COMPILE |
|
24 done=1; |
|
25 +#endif |
|
26 |
|
27 #ifdef LDAP_R_COMPILE |
|
28 + /* use static mutex to protect mutex initialization */ |
|
29 + (void) LDAP_MUTEX_LOCK(&ldap_int_utils_init_mutex); |
|
30 + if (done) { |
|
31 + (void) LDAP_MUTEX_UNLOCK(&ldap_int_utils_init_mutex); |
|
32 + return; |
|
33 + } |
|
34 #if !defined( USE_CTIME_R ) && !defined( HAVE_REENTRANT_FUNCTIONS ) |
|
35 ldap_pvt_thread_mutex_init( &ldap_int_ctime_mutex ); |
|
36 #endif |
|
37 @@ -718,9 +727,13 @@ |
|
38 #ifdef HAVE_GSSAPI |
|
39 ldap_pvt_thread_mutex_init( &ldap_int_gssapi_mutex ); |
|
40 #endif |
|
41 + |
|
42 + done=1; |
|
43 + /* use static mutex to protect mutex initialization */ |
|
44 + (void) LDAP_MUTEX_UNLOCK(&ldap_int_utils_init_mutex); |
|
45 #endif |
|
46 |
|
47 /* call other module init functions here... */ |
|
48 } |
|
49 |
|
50 #if defined( NEED_COPY_HOSTENT ) |