diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2007-09-14 20:48:47 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2007-09-14 20:48:47 +0200 |
commit | 7069a23f05935e48dcda49d05994ad4df742a80f (patch) | |
tree | 8248763b670d44c129e9ca0375676b64a23e522d | |
parent | c5fde824853997d98807b9a51585e4544e86d048 (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
-rw-r--r-- | nslcd/alias.c | 2 | ||||
-rw-r--r-- | nslcd/ether.c | 2 | ||||
-rw-r--r-- | nslcd/group.c | 11 | ||||
-rw-r--r-- | nslcd/host.c | 2 | ||||
-rw-r--r-- | nslcd/ldap-nss.c | 120 | ||||
-rw-r--r-- | nslcd/ldap-nss.h | 69 | ||||
-rw-r--r-- | nslcd/network.c | 2 | ||||
-rw-r--r-- | nslcd/passwd.c | 2 | ||||
-rw-r--r-- | nslcd/protocol.c | 2 | ||||
-rw-r--r-- | nslcd/rpc.c | 2 | ||||
-rw-r--r-- | nslcd/service.c | 2 | ||||
-rw-r--r-- | nslcd/shadow.c | 2 | ||||
-rw-r--r-- | nslcd/util.c | 27 |
13 files changed, 50 insertions, 195 deletions
diff --git a/nslcd/alias.c b/nslcd/alias.c index ad98ca4..0593c6d 100644 --- a/nslcd/alias.c +++ b/nslcd/alias.c @@ -187,9 +187,7 @@ int nslcd_alias_all(TFILE *fp,MYLDAP_SESSION *session) WRITE_INT32(fp,retv); WRITE_FLUSH(fp); /* FIXME: if a previous call returns what happens to the context? */ - _nss_ldap_enter(); _nss_ldap_ent_context_cleanup(&context); - _nss_ldap_leave(); /* we're done */ return 0; } diff --git a/nslcd/ether.c b/nslcd/ether.c index 4437bed..7aee6a7 100644 --- a/nslcd/ether.c +++ b/nslcd/ether.c @@ -264,9 +264,7 @@ int nslcd_ether_all(TFILE *fp,MYLDAP_SESSION *session) WRITE_INT32(fp,retv); WRITE_FLUSH(fp); /* FIXME: if a previous call returns what happens to the context? */ - _nss_ldap_enter(); _nss_ldap_ent_context_cleanup(&context); - _nss_ldap_leave(); /* we're done */ return 0; } diff --git a/nslcd/group.c b/nslcd/group.c index bffc2b7..16824b4 100644 --- a/nslcd/group.c +++ b/nslcd/group.c @@ -181,7 +181,7 @@ static char *user2dn(MYLDAP_SESSION *session,const char *user) char filter[1024]; LDAPMessage *res, *e; mkfilter_passwd_byname(user,filter,sizeof(filter)); - if (_nss_ldap_search_sync_locked(session,group_base,group_scope,filter,no_attrs,1,&res)==NSS_STATUS_SUCCESS) + if (_nss_ldap_search_sync(session,group_base,group_scope,filter,no_attrs,1,&res)==NSS_STATUS_SUCCESS) { e=_nss_ldap_first_entry(session,res); if (e!=NULL) @@ -997,9 +997,9 @@ static enum nss_status ng_chase(MYLDAP_SESSION *session,const char *dn,ldap_init gidnumber_attrs[0]=attmap_group_gidNumber; gidnumber_attrs[1]=NULL; - _nss_ldap_ent_context_init_locked(&context,session); + _nss_ldap_ent_context_init(&context,session); mkfilter_getgroupsbydn(dn,filter,sizeof(filter)); - stat=_nss_ldap_getent_locked(&context,lia,NULL,0,&erange, + stat=_nss_ldap_getent(&context,lia,NULL,0,&erange, group_base,group_scope,filter,gidnumber_attrs, do_parse_initgroups_nested); @@ -1097,13 +1097,11 @@ static int group_bymember(MYLDAP_SESSION *session,const char *user, log_log(LOG_DEBUG,"==> group_bymember (user=%s)",user); lia.depth = 0; lia.known_groups=NULL; - _nss_ldap_enter(); /* initialize schema */ stat=_nss_ldap_init(session); if (stat!=NSS_STATUS_SUCCESS) { log_log(LOG_DEBUG,"<== group_bymember (init failed)"); - _nss_ldap_leave(); return -1; } mkfilter_group_bymember(session,user,filter,sizeof(filter)); @@ -1115,7 +1113,6 @@ static int group_bymember(MYLDAP_SESSION *session,const char *user, do_parse_initgroups_nested); _nss_ldap_namelist_destroy(&lia.known_groups); _nss_ldap_ent_context_cleanup(&context); - _nss_ldap_leave(); if ((stat!=NSS_STATUS_SUCCESS)&&(stat!=NSS_STATUS_NOTFOUND)) { log_log(LOG_DEBUG,"<== group_bymember (not found)"); @@ -1298,9 +1295,7 @@ int nslcd_group_all(TFILE *fp,MYLDAP_SESSION *session) WRITE_INT32(fp,retv); WRITE_FLUSH(fp); /* FIXME: if a previous call returns what happens to the context? */ - _nss_ldap_enter(); _nss_ldap_ent_context_cleanup(&context); - _nss_ldap_leave(); /* we're done */ return 0; } diff --git a/nslcd/host.c b/nslcd/host.c index f491d41..589a16a 100644 --- a/nslcd/host.c +++ b/nslcd/host.c @@ -406,9 +406,7 @@ int nslcd_host_all(TFILE *fp,MYLDAP_SESSION *session) WRITE_INT32(fp,retv); WRITE_FLUSH(fp); /* FIXME: if a previous call returns what happens to the context? */ - _nss_ldap_enter(); _nss_ldap_ent_context_cleanup(&context); - _nss_ldap_leave(); /* we're done */ return 0; } diff --git a/nslcd/ldap-nss.c b/nslcd/ldap-nss.c index 0a530f6..86dbe1c 100644 --- a/nslcd/ldap-nss.c +++ b/nslcd/ldap-nss.c @@ -83,9 +83,6 @@ #include "attmap.h" #include "compat/ldap.h" -/* TODO: move the lock inside the session */ -NSS_LDAP_DEFINE_LOCK(global_lock); - /* * LS_INIT only used for enumeration contexts */ @@ -294,22 +291,6 @@ static int do_rebind(LDAP *ld,LDAP_CONST char UNUSED(*url), } /* - * Acquires global lock. - */ -void _nss_ldap_enter(void) -{ - NSS_LDAP_LOCK(global_lock); -} - -/* - * Releases global mutex. - */ -void _nss_ldap_leave(void) -{ - NSS_LDAP_UNLOCK(global_lock); -} - -/* * Disable keepalive on a LDAP connection's socket. */ static void do_set_sockopts(MYLDAP_SESSION *session) @@ -331,9 +312,6 @@ static void do_set_sockopts(MYLDAP_SESSION *session) /* * Close the global session, sending an unbind. * Closes connection to the LDAP server. - * This assumes that we have exclusive access to session->ls_conn, - * either by some other function having acquired a lock, or by - * using a thread safe libldap. */ static void do_close(MYLDAP_SESSION *session) { @@ -481,9 +459,6 @@ static int do_ssl_options(void) * Opens connection to an LDAP server - should only be called from search * API. Other API that just needs access to configuration and schema should * call _nss_ldap_init(). - * - * As with do_close(), this assumes ownership of sess. - * It also wants to own __config: is there a potential deadlock here? XXX */ static enum nss_status do_open(MYLDAP_SESSION *session) { @@ -671,28 +646,13 @@ static enum nss_status do_result_async(struct ent_context *context,int all) } /* - * This function initializes an enumeration context, acquiring - * the global mutex. - * - * It could be done from the default constructor, under Solaris, but we - * delay it until the setXXent() function is called. - */ -void _nss_ldap_ent_context_init(struct ent_context *context,MYLDAP_SESSION *session) -{ - _nss_ldap_enter(); - _nss_ldap_ent_context_init_locked(context,session); - _nss_ldap_leave(); -} - -/* * This function initializes an enumeration context. * * It could be done from the default constructor, under Solaris, but we * delay it until the setXXent() function is called. */ -void _nss_ldap_ent_context_init_locked(struct ent_context *context,MYLDAP_SESSION *session) +void _nss_ldap_ent_context_init(struct ent_context *context,MYLDAP_SESSION *session) { - /* TODO: find out why we need to have aquired a lock for this */ context->session=session; context->ec_cookie=NULL; context->ec_res=NULL; @@ -701,8 +661,7 @@ void _nss_ldap_ent_context_init_locked(struct ent_context *context,MYLDAP_SESSIO } /* - * Clears a given context; we require the caller - * to acquire the lock. + * Clears a given context. */ void _nss_ldap_ent_context_cleanup(struct ent_context *context) { @@ -734,7 +693,7 @@ void _nss_ldap_ent_context_cleanup(struct ent_context *context) /* * Synchronous search function. Don't call this directly; * always wrap calls to this with do_with_reconnect(), or, - * better still, use _nss_ldap_search_locked(). + * better still, use _nss_ldap_search(). */ static int do_search_sync( MYLDAP_SESSION *session,const char *base,int scope, @@ -1121,15 +1080,14 @@ char *_nss_ldap_next_attribute(MYLDAP_SESSION *session,LDAPMessage *entry,BerEle /* * The generic synchronous lookup cover function. - * Assumes caller holds lock. */ -enum nss_status _nss_ldap_search_sync_locked( +enum nss_status _nss_ldap_search_sync( MYLDAP_SESSION *session,const char *base,int scope, const char *filter,const char **attrs,int sizelimit, LDAPMessage **res) { enum nss_status stat; - log_log(LOG_DEBUG,"_nss_ldap_search_sync_locked(base=\"%s\", filter=\"%s\")",base,filter); + log_log(LOG_DEBUG,"_nss_ldap_search_sync(base=\"%s\", filter=\"%s\")",base,filter); /* initilize session */ if ((stat=_nss_ldap_init(session))!=NSS_STATUS_SUCCESS) { @@ -1143,14 +1101,13 @@ enum nss_status _nss_ldap_search_sync_locked( /* * The generic lookup cover function (asynchronous). - * Assumes caller holds lock. */ -static enum nss_status _nss_ldap_search_async_locked( +static enum nss_status _nss_ldap_search_async( MYLDAP_SESSION *session,const char *base,int scope, const char *filter,const char **attrs,int sizelimit,int *msgid) { enum nss_status stat; - log_log(LOG_DEBUG,"_nss_ldap_search_async_locked(base=\"%s\", filter=\"%s\")",base,filter); + log_log(LOG_DEBUG,"_nss_ldap_search_async(base=\"%s\", filter=\"%s\")",base,filter); *msgid=-1; /* initialize session */ if ((stat=_nss_ldap_init(session))!=NSS_STATUS_SUCCESS) @@ -1200,50 +1157,26 @@ static int nss2nslcd(enum nss_status code) } /* - * General entry point for enumeration routines. + * Internal entry point for enumeration routines. * This should really use the asynchronous LDAP search API to avoid * pulling down all the entries at once, particularly if the * enumeration is not completed. - * Locks mutex. - */ -int _nss_ldap_getent(struct ent_context *context, - void *result,char *buffer,size_t buflen,int *errnop, - const char *base,int scope,const char *filter, - const char **attrs,parser_t parser) -{ - int status; - /* - * we need to lock here as the context may not be thread-specific - * data (under glibc, for example). Maybe we should make the lock part - * of the context. - */ - _nss_ldap_enter(); - status=nss2nslcd(_nss_ldap_getent_locked(context,result, - buffer,buflen,errnop, - base,scope,filter,attrs,parser)); - _nss_ldap_leave(); - return status; -} - -/* - * Internal entry point for enumeration routines. - * Caller holds global mutex */ -enum nss_status _nss_ldap_getent_locked( +int _nss_ldap_getent( struct ent_context *context,void *result,char *buffer,size_t buflen,int *errnop, const char *base,int scope,const char *filter,const char **attrs, parser_t parser) { enum nss_status stat=NSS_STATUS_SUCCESS; int msgid; - log_log(LOG_DEBUG,"_nss_ldap_getent_locked(base=\"%s\", filter=\"%s\")",base,filter); + log_log(LOG_DEBUG,"_nss_ldap_getent(base=\"%s\", filter=\"%s\")",base,filter); /* if context->ec_msgid < 0, then we haven't searched yet */ if (context->ec_msgid<0) { /* set up a new search */ - stat=_nss_ldap_search_async_locked(context->session,base,scope,filter,attrs,LDAP_NO_LIMIT,&msgid); + stat=_nss_ldap_search_async(context->session,base,scope,filter,attrs,LDAP_NO_LIMIT,&msgid); if (stat != NSS_STATUS_SUCCESS) - return stat; + return nss2nslcd(stat); context->ec_msgid=msgid; } @@ -1257,18 +1190,17 @@ enum nss_status _nss_ldap_getent_locked( { stat=do_next_page(context->session,base,scope,filter,attrs,LDAP_NO_LIMIT,&msgid,context->ec_cookie); if (stat!=NSS_STATUS_SUCCESS) - return stat; + return nss2nslcd(stat); context->ec_msgid=msgid; /* retry parsing a result */ stat=do_parse_async(context,result,buffer,buflen,errnop,parser); } } - return stat; + return nss2nslcd(stat); } /* * General match function. - * Locks mutex. */ int _nss_ldap_getbyname(MYLDAP_SESSION *session,void *result, char *buffer, size_t buflen,int *errnop, const char *base,int scope,const char *filter,const char **attrs, @@ -1278,18 +1210,13 @@ int _nss_ldap_getbyname(MYLDAP_SESSION *session,void *result, char *buffer, size enum nss_status stat = NSS_STATUS_NOTFOUND; struct ent_context context; - _nss_ldap_enter(); - log_log(LOG_DEBUG,"_nss_ldap_getbyname(base=\"%s\", filter=\"%s\"",base,filter); - _nss_ldap_ent_context_init_locked(&context,session); + _nss_ldap_ent_context_init(&context,session); - stat=_nss_ldap_search_sync_locked(context.session,base,scope,filter,attrs,1,&context.ec_res); + stat=_nss_ldap_search_sync(context.session,base,scope,filter,attrs,1,&context.ec_res); if (stat!=NSS_STATUS_SUCCESS) - { - _nss_ldap_leave(); return nss2nslcd(stat); - } /* * we pass this along for the benefit of the services parser, @@ -1305,9 +1232,6 @@ int _nss_ldap_getbyname(MYLDAP_SESSION *session,void *result, char *buffer, size _nss_ldap_ent_context_cleanup(&context); - /* moved unlock here to avoid race condition bug #49 */ - _nss_ldap_leave(); - return nss2nslcd(stat); } @@ -1364,27 +1288,19 @@ int _nss_ldap_searchbyname( struct ent_context context; int32_t tmpint32; - _nss_ldap_enter(); - - _nss_ldap_ent_context_init_locked(&context,session); + _nss_ldap_ent_context_init(&context,session); - stat=nss2nslcd(_nss_ldap_search_sync_locked(session,base,scope,filter,attrs,1,&context.ec_res)); + stat=nss2nslcd(_nss_ldap_search_sync(session,base,scope,filter,attrs,1,&context.ec_res)); /* write the result code */ WRITE_INT32(fp,stat); /* bail on nothing found */ if (stat!=NSLCD_RESULT_SUCCESS) - { - _nss_ldap_leave(); return 1; - } /* call the parser for the result */ stat=NEW_do_parse_sync(&context,fp,parser); _nss_ldap_ent_context_cleanup(&context); - /* moved unlock here to avoid race condition bug #49 */ - _nss_ldap_leave(); - return stat; } diff --git a/nslcd/ldap-nss.h b/nslcd/ldap-nss.h index 22a307f..b0188bf 100644 --- a/nslcd/ldap-nss.h +++ b/nslcd/ldap-nss.h @@ -26,13 +26,6 @@ #ifndef _LDAP_NSS_LDAP_LDAP_NSS_H #define _LDAP_NSS_LDAP_LDAP_NSS_H -/* 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 <time.h> #include <sys/socket.h> #include <netinet/in.h> @@ -120,48 +113,7 @@ typedef enum nss_status (*parser_t)(MYLDAP_SESSION *session,LDAPMessage *e, typedef int (*NEWparser_t)(MYLDAP_SESSION *session,LDAPMessage *e,struct ldap_state *pvt,TFILE *fp); /* - * 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 - -/* - * Acquire global nss_ldap lock and blocks SIGPIPE. - * Generally this should only be done within ldap-nss.c. - */ -void _nss_ldap_enter(void); - -/* - * Release global nss_ldap lock and blocks SIGPIPE. - * Generally this should only be done within ldap-nss.c. - */ -void _nss_ldap_leave(void); - -/* - * _nss_ldap_ent_context_init_locked() has the same behaviour - * as above, except it assumes that the caller has acquired - * the lock - */ -void _nss_ldap_ent_context_init_locked(struct ent_context *context,MYLDAP_SESSION *session); - -/* * _nss_ldap_ent_context_init() is called for each getXXent() call - * This will acquire the global mutex. */ void _nss_ldap_ent_context_init(struct ent_context *context,MYLDAP_SESSION *session); @@ -180,9 +132,9 @@ char *_nss_ldap_first_attribute(MYLDAP_SESSION *session,LDAPMessage *entry,BerEl char *_nss_ldap_next_attribute(MYLDAP_SESSION *session,LDAPMessage *entry,BerElement *ber); /* - * Synchronous search cover (caller acquires lock). + * Synchronous search cover. */ -enum nss_status _nss_ldap_search_sync_locked( +enum nss_status _nss_ldap_search_sync( MYLDAP_SESSION *session,const char *base,int scope, const char *filter,const char **attrs,int sizelimit, LDAPMessage **res); @@ -203,24 +155,7 @@ enum nss_status _nss_ldap_read_sync ( LDAPMessage ** res /* OUT */ ); /* - * extended enumeration routine; uses asynchronous API. - * Caller must have acquired the global mutex - */ -enum nss_status _nss_ldap_getent_locked ( - struct ent_context *context, /* IN/OUT */ - void *result, /* IN/OUT */ - char *buffer, /* IN */ - size_t buflen, /* IN */ - int *errnop, /* OUT */ - const char *base, /* IN */ - int scope, /* IN */ - const char *filter, /* IN */ - const char **attrs, /* IN */ - parser_t parser /* IN */ ); - -/* * common enumeration routine; uses asynchronous API. - * Acquires the global mutex */ int _nss_ldap_getent( struct ent_context *context, /* IN/OUT */ diff --git a/nslcd/network.c b/nslcd/network.c index d098973..6cac598 100644 --- a/nslcd/network.c +++ b/nslcd/network.c @@ -298,9 +298,7 @@ int nslcd_network_all(TFILE *fp,MYLDAP_SESSION *session) WRITE_INT32(fp,retv); WRITE_FLUSH(fp); /* FIXME: if a previous call returns what happens to the context? */ - _nss_ldap_enter(); _nss_ldap_ent_context_cleanup(&context); - _nss_ldap_leave(); /* we're done */ return 0; } diff --git a/nslcd/passwd.c b/nslcd/passwd.c index 15634f6..99fc596 100644 --- a/nslcd/passwd.c +++ b/nslcd/passwd.c @@ -331,9 +331,7 @@ int nslcd_passwd_all(TFILE *fp,MYLDAP_SESSION *session) WRITE_INT32(fp,retv); WRITE_FLUSH(fp); /* FIXME: if some statement returns what happens to the context? */ - _nss_ldap_enter(); _nss_ldap_ent_context_cleanup(&context); - _nss_ldap_leave(); /* we're done */ return 0; } diff --git a/nslcd/protocol.c b/nslcd/protocol.c index 6dbc880..f26e738 100644 --- a/nslcd/protocol.c +++ b/nslcd/protocol.c @@ -249,9 +249,7 @@ int nslcd_protocol_all(TFILE *fp,MYLDAP_SESSION *session) WRITE_INT32(fp,retv); WRITE_FLUSH(fp); /* FIXME: if a previous call returns what happens to the context? */ - _nss_ldap_enter(); _nss_ldap_ent_context_cleanup(&context); - _nss_ldap_leave(); /* we're done */ return 0; } diff --git a/nslcd/rpc.c b/nslcd/rpc.c index a8e7263..aec6cdd 100644 --- a/nslcd/rpc.c +++ b/nslcd/rpc.c @@ -259,9 +259,7 @@ int nslcd_rpc_all(TFILE *fp,MYLDAP_SESSION *session) WRITE_INT32(fp,retv); WRITE_FLUSH(fp); /* FIXME: if a previous call returns what happens to the context? */ - _nss_ldap_enter(); _nss_ldap_ent_context_cleanup(&context); - _nss_ldap_leave(); /* we're done */ return 0; } diff --git a/nslcd/service.c b/nslcd/service.c index fccb262..ddd9583 100644 --- a/nslcd/service.c +++ b/nslcd/service.c @@ -370,9 +370,7 @@ int nslcd_service_all(TFILE *fp,MYLDAP_SESSION *session) WRITE_INT32(fp,retv); WRITE_FLUSH(fp); /* FIXME: if a previous call returns what happens to the context? */ - _nss_ldap_enter(); _nss_ldap_ent_context_cleanup(&context); - _nss_ldap_leave(); /* we're done */ return 0; } diff --git a/nslcd/shadow.c b/nslcd/shadow.c index 9d4f02a..7d15883 100644 --- a/nslcd/shadow.c +++ b/nslcd/shadow.c @@ -268,9 +268,7 @@ int nslcd_shadow_all(TFILE *fp,MYLDAP_SESSION *session) WRITE_INT32(fp,retv); WRITE_FLUSH(fp); /* FIXME: if a previous call returns what happens to the context? */ - _nss_ldap_enter(); _nss_ldap_ent_context_cleanup(&context); - _nss_ldap_leave(); /* we're done */ return 0; } 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; |