From d5e133f459bb444ac9ec322283ea8de23bb3cff8 Mon Sep 17 00:00:00 2001 From: Ryan Tandy Date: Thu, 16 Apr 2020 10:46:18 -0700 Subject: [PATCH] ITS#9181 fix ldap_pvt_thread_mutex_t used before its definition --- include/ldap_int_thread.h | 4 ++-- libraries/libldap_r/thr_nt.c | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/ldap_int_thread.h b/include/ldap_int_thread.h index 07fbd67e7b..16b6f49648 100644 --- a/include/ldap_int_thread.h +++ b/include/ldap_int_thread.h @@ -153,12 +153,12 @@ typedef HANDLE ldap_int_thread_cond_t; typedef DWORD ldap_int_thread_key_t; LDAP_F( int ) -ldap_pvt_thread_mutex_init_first LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); +ldap_int_mutex_firstcreate LDAP_P(( ldap_int_thread_mutex_t *mutex )); #ifndef LDAP_INT_MUTEX_NULL #define LDAP_INT_MUTEX_NULL ((HANDLE)0) #define LDAP_INT_MUTEX_FIRSTCREATE(m) \ - ldap_pvt_thread_mutex_init_first(&(m)) + ldap_int_mutex_firstcreate(&(m)) #endif LDAP_END_DECL diff --git a/libraries/libldap_r/thr_nt.c b/libraries/libldap_r/thr_nt.c index 0c1b36d95c..c61a62b132 100644 --- a/libraries/libldap_r/thr_nt.c +++ b/libraries/libldap_r/thr_nt.c @@ -54,6 +54,17 @@ ldap_int_thread_destroy( void ) return 0; } +int +ldap_int_mutex_firstcreate( ldap_int_thread_mutex_t *mutex ) +{ + if ( *mutex == NULL ) { + HANDLE p = CreateMutex( NULL, 0, NULL ); + if ( InterlockedCompareExchangePointer((PVOID*)mutex, (PVOID)p, NULL) != NULL) + CloseHandle( p ); + } + return 0; +} + int ldap_pvt_thread_create( ldap_pvt_thread_t * thread, int detach, @@ -161,17 +172,6 @@ ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) return ( 0 ); } -int -ldap_pvt_thread_mutex_init_first( ldap_pvt_thread_mutex_t *mutex ) -{ - if ( *mutex == NULL ) { - HANDLE p = CreateMutex( NULL, 0, NULL ); - if ( InterlockedCompareExchangePointer((PVOID*)mutex, (PVOID)p, NULL) != NULL) - CloseHandle( p ); - } - return ( 0 ); -} - int ldap_pvt_thread_mutex_recursive_init( ldap_pvt_thread_mutex_t *mutex ) {