]> git.sur5r.net Git - openldap/commitdiff
ITS#6625 concurrency patch cleanup
authorHallvard Furuseth <hallvard@openldap.org>
Mon, 6 Dec 2010 10:41:41 +0000 (10:41 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Mon, 6 Dec 2010 10:41:41 +0000 (10:41 +0000)
include/ldap_int_thread.h
include/ldap_pvt_thread.h
libraries/libldap/init.c
libraries/libldap/ldap-int.h

index 108574272f528b19fd82722a3f8bc53213e58477..531b502eeb13788a5c61d3ebb9410a0424b8d2bd 100644 (file)
@@ -69,9 +69,9 @@ typedef pthread_key_t         ldap_int_thread_key_t;
 typedef pthread_rwlock_t ldap_int_thread_rdwr_t;
 #endif
 
-#ifndef        LDO_MUTEX_NULL
-#define LDO_MUTEX_NULL ,PTHREAD_MUTEX_INITIALIZER
-#define MUTEX_FIRSTCREATE(m)
+#ifndef LDAP_INT_MUTEX_NULL
+#define LDAP_INT_MUTEX_NULL    PTHREAD_MUTEX_INITIALIZER
+#define LDAP_INT_MUTEX_FIRSTCREATE(m)  ((void) 0)
 #endif
 
 LDAP_END_DECL
@@ -96,9 +96,9 @@ typedef struct mutex          ldap_int_thread_mutex_t;
 typedef struct condition       ldap_int_thread_cond_t;
 typedef cthread_key_t          ldap_int_thread_key_t;
 
-#ifndef        LDO_MUTEX_NULL
-#define LDO_MUTEX_NULL ,MUTEX_INITIALIZER
-#define MUTEX_FIRSTCREATE(m)
+#ifndef LDAP_INT_MUTEX_NULL
+#define LDAP_INT_MUTEX_NULL    MUTEX_INITIALIZER
+#define LDAP_INT_MUTEX_FIRSTCREATE(m)  ((void) 0)
 #endif
 
 LDAP_END_DECL
@@ -125,9 +125,9 @@ typedef pth_key_t   ldap_int_thread_key_t;
 typedef pth_rwlock_t ldap_int_thread_rdwr_t;
 #endif
 
-#ifndef        LDO_MUTEX_NULL
-#define LDO_MUTEX_NULL ,PTH_MUTEX_INIT
-#define MUTEX_FIRSTCREATE(m)
+#ifndef LDAP_INT_MUTEX_NULL
+#define LDAP_INT_MUTEX_NULL    PTH_MUTEX_INIT
+#define LDAP_INT_MUTEX_FIRSTCREATE(m)  ((void) 0)
 #endif
 
 LDAP_END_DECL
@@ -158,9 +158,9 @@ typedef thread_key_t        ldap_int_thread_key_t;
 #define LDAP_THREAD_HAVE_SETCONCURRENCY 1
 #endif
 
-#ifndef        LDO_MUTEX_NULL
-#define LDO_MUTEX_NULL ,DEFAULTMUTEX
-#define MUTEX_FIRSTCREATE(m)
+#ifndef LDAP_INT_MUTEX_NULL
+#define LDAP_INT_MUTEX_NULL    DEFAULTMUTEX
+#define LDAP_INT_MUTEX_FIRSTCREATE(m)  ((void) 0)
 #endif
 
 #elif defined(HAVE_NT_THREADS)
@@ -180,9 +180,10 @@ typedef HANDLE     ldap_int_thread_mutex_t;
 typedef HANDLE ldap_int_thread_cond_t;
 typedef DWORD  ldap_int_thread_key_t;
 
-#ifndef        LDO_MUTEX_NULL
-#define LDO_MUTEX_NULL         ,(HANDLE)0
-#define MUTEX_FIRSTCREATE(m)   (!m ? 0 : ldap_pvt_thread_mutex_init(&m) )
+#ifndef LDAP_INT_MUTEX_NULL
+#define LDAP_INT_MUTEX_NULL            ((HANDLE)0)
+#define LDAP_INT_MUTEX_FIRSTCREATE(m) \
+               ((void) ((m) && ldap_int_thread_mutex_init(&(m))))
 #endif
 
 LDAP_END_DECL
@@ -209,9 +210,9 @@ typedef int                 ldap_int_thread_key_t;
 #define LDAP_THREAD_HAVE_TPOOL 1
 typedef int                    ldap_int_thread_pool_t;
 
-#ifndef        LDO_MUTEX_NULL
-#define LDO_MUTEX_NULL
-#define MUTEX_FIRSTCREATE(m)
+#ifndef LDAP_INT_MUTEX_NULL
+#define LDAP_INT_MUTEX_NULL                            0
+#define LDAP_INT_MUTEX_FIRSTCREATE(m)  ((void) 0)
 #endif
 
 LDAP_END_DECL
@@ -284,6 +285,10 @@ typedef struct {
        ldap_int_thread_t       owner;
 } ldap_debug_thread_mutex_t;
 
+#define        LDAP_DEBUG_MUTEX_NULL   {LDAP_INT_MUTEX_NULL, {0,0,{0},0} /*,owner*/}
+#define        LDAP_DEBUG_MUTEX_FIRSTCREATE(m) \
+       ((void) ((m).usage.state || ldap_pvt_thread_mutex_init(&(m))))
+
 typedef struct {
        ldap_int_thread_cond_t  wrapped;
        ldap_debug_usage_info_t usage;
index 6060b21d0efe68ad6e19f8d6c38fb487918098b9..e9f591eaed414aac4d936a17241aa3820fd5cf26 100644 (file)
@@ -28,10 +28,14 @@ typedef ldap_int_thread_t                   ldap_pvt_thread_t;
 typedef ldap_debug_thread_mutex_t      ldap_pvt_thread_mutex_t;
 typedef ldap_debug_thread_cond_t       ldap_pvt_thread_cond_t;
 typedef ldap_debug_thread_rdwr_t       ldap_pvt_thread_rdwr_t;
+#define LDAP_PVT_MUTEX_FIRSTCREATE     LDAP_DEBUG_MUTEX_FIRSTCREATE
+#define LDAP_PVT_MUTEX_NULL                    LDAP_DEBUG_MUTEX_NULL
 #else
 typedef ldap_int_thread_mutex_t                ldap_pvt_thread_mutex_t;
 typedef ldap_int_thread_cond_t         ldap_pvt_thread_cond_t;
 typedef ldap_int_thread_rdwr_t         ldap_pvt_thread_rdwr_t;
+#define LDAP_PVT_MUTEX_FIRSTCREATE     LDAP_INT_MUTEX_FIRSTCREATE
+#define LDAP_PVT_MUTEX_NULL                    LDAP_INT_MUTEX_NULL
 #endif
 typedef ldap_int_thread_rmutex_t       ldap_pvt_thread_rmutex_t;
 typedef ldap_int_thread_key_t  ldap_pvt_thread_key_t;
index afdf893ba0ab4e547a0e6e66c69c85d7b43d2bf9..aca545a2d843aaa1e4745dd21e499a1548073ee2 100644 (file)
@@ -36,7 +36,7 @@
 #include "lutil.h"
 
 struct ldapoptions ldap_int_global_options =
-       { LDAP_UNINITIALIZED, LDAP_DEBUG_NONE LDO_MUTEX_NULL };  
+       { LDAP_UNINITIALIZED, LDAP_DEBUG_NONE LDAP_LDO_MUTEX_NULLARG };  
 
 #define ATTR_NONE      0
 #define ATTR_BOOL      1
@@ -510,7 +510,7 @@ ldap_int_destroy_global_options(void)
  */
 void ldap_int_initialize_global_options( struct ldapoptions *gopts, int *dbglvl )
 {
-       MUTEX_FIRSTCREATE(gopts->ldo_mutex);
+       LDAP_PVT_MUTEX_FIRSTCREATE(gopts->ldo_mutex);
        LDAP_MUTEX_LOCK( &gopts->ldo_mutex );
        if (gopts->ldo_valid == LDAP_INITIALIZED) {
                /* someone else got here first */
index e818900bcb76ad4a3ddd95ae8faf5053b7d6afe6..b350224f57a5c7c0f0f9632efdc0785780bfa051 100644 (file)
@@ -183,12 +183,15 @@ struct ldapoptions {
 #define LDAP_VALID_SESSION     0x2
 #define LDAP_TRASHED_SESSION   0xFF
        int   ldo_debug;
+
 #ifdef LDAP_R_COMPILE
        ldap_pvt_thread_mutex_t ldo_mutex;
+#define LDAP_LDO_MUTEX_NULLARG , LDAP_PVT_MUTEX_NULL
 #else
-#define LDO_MUTEX_NULL
-#define MUTEX_FIRSTCREATE(m)
+#define LDAP_LDO_MUTEX_NULLARG
+#define LDAP_PVT_MUTEX_FIRSTCREATE(m)  ((void) 0)
 #endif
+
 #ifdef LDAP_CONNECTIONLESS
 #define        LDAP_IS_UDP(ld)         ((ld)->ld_options.ldo_is_udp)
        void*                   ldo_peer;       /* struct sockaddr* */
@@ -494,19 +497,16 @@ LDAP_V( ldap_pvt_thread_mutex_t ) ldap_int_gssapi_mutex;
 #define LDAP_ASSERT_MUTEX_OWNER(mutex) \
        LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER(mutex)
 #else
-#define LDAP_MUTEX_LOCK(mutex)
-#define LDAP_MUTEX_UNLOCK(mutex)
-#define LDAP_ASSERT_MUTEX_OWNER(mutex)
+#define LDAP_MUTEX_LOCK(mutex)    ((void) 0)
+#define LDAP_MUTEX_UNLOCK(mutex)  ((void) 0)
+#define LDAP_ASSERT_MUTEX_OWNER(mutex) ((void) 0)
 #endif
 
-#ifdef LDAP_R_COMPILE
-#define        LDAP_NEXT_MSGID(ld, id) \
+#define        LDAP_NEXT_MSGID(ld, id) do { \
        LDAP_MUTEX_LOCK( &(ld)->ld_msgid_mutex ); \
-       id = ++(ld)->ld_msgid; \
-       LDAP_MUTEX_UNLOCK( &(ld)->ld_msgid_mutex )
-#else
-#define        LDAP_NEXT_MSGID(ld, id) id = ++(ld)->ld_msgid
-#endif
+       (id) = ++(ld)->ld_msgid; \
+       LDAP_MUTEX_UNLOCK( &(ld)->ld_msgid_mutex ); \
+} while (0)
 
 /*
  * in abandon.c