summaryrefslogtreecommitdiff
path: root/nslcd/util.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2007-09-14 18:48:47 +0000
committerArthur de Jong <arthur@arthurdejong.org>2007-09-14 18:48:47 +0000
commit7069a23f05935e48dcda49d05994ad4df742a80f (patch)
tree8248763b670d44c129e9ca0375676b64a23e522d /nslcd/util.c
parentc5fde824853997d98807b9a51585e4544e86d048 (diff)
remove mutex from all LDAP operations because we now have a session and a connection per thread
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@392 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nslcd/util.c')
-rw-r--r--nslcd/util.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/nslcd/util.c b/nslcd/util.c
index d6a9807..73be117 100644
--- a/nslcd/util.c
+++ b/nslcd/util.c
@@ -49,6 +49,13 @@
#include <pthread.h>
#endif
+/* for glibc, use weak aliases to pthreads functions */
+#ifdef HAVE_LIBC_LOCK_H
+#include <libc-lock.h>
+#elif defined(HAVE_BITS_LIBC_LOCK_H)
+#include <bits/libc-lock.h>
+#endif
+
#include "ldap-nss.h"
#include "util.h"
#include "common.h"
@@ -56,6 +63,26 @@
#include "cfg.h"
#include "attmap.h"
+/*
+ * Portable locking macro.
+ */
+#if defined(HAVE_THREAD_H)
+#define NSS_LDAP_LOCK(m) mutex_lock(&m)
+#define NSS_LDAP_UNLOCK(m) mutex_unlock(&m)
+#define NSS_LDAP_DEFINE_LOCK(m) static mutex_t m = DEFAULTMUTEX
+#elif defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
+#define NSS_LDAP_LOCK(m) __libc_lock_lock(m)
+#define NSS_LDAP_UNLOCK(m) __libc_lock_unlock(m)
+#define NSS_LDAP_DEFINE_LOCK(m) static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER
+#elif defined(HAVE_PTHREAD_H)
+#define NSS_LDAP_LOCK(m) pthread_mutex_lock(&m)
+#define NSS_LDAP_UNLOCK(m) pthread_mutex_unlock(&m)
+#define NSS_LDAP_DEFINE_LOCK(m) static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER
+#else
+#define NSS_LDAP_LOCK(m)
+#define NSS_LDAP_UNLOCK(m)
+#define NSS_LDAP_DEFINE_LOCK(m)
+#endif
static void *__cache = NULL;