Commit 7cb9c496 authored by Hallvard Furuseth's avatar Hallvard Furuseth
Browse files

ITS#6625 concurrency patch cleanup

parent 87a9ee9e
......@@ -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;
......
......@@ -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;
......
......@@ -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 */
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment