From 0e7a9da79d418a8e55590bfa69cb8e6380279fe9 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga <kurt@openldap.org> Date: Mon, 25 Jun 2001 06:56:08 +0000 Subject: [PATCH] Cyrus SASL locking --- libraries/libldap/cyrus.c | 8 ++++++-- libraries/libldap/sasl.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c index 6af6d8940c..fcca106b7d 100644 --- a/libraries/libldap/cyrus.c +++ b/libraries/libldap/cyrus.c @@ -16,11 +16,13 @@ #include <ac/ctype.h> #include "ldap-int.h" + +#ifdef HAVE_CYRUS_SASL + #ifdef LDAP_R_COMPILE -#include "ldap_pvt_thread.h" +ldap_pvt_thread_mutex_t ldap_int_sasl_mutex; #endif -#ifdef HAVE_CYRUS_SASL #include <sasl.h> /* @@ -62,6 +64,8 @@ int ldap_int_sasl_init( void ) ldap_pvt_sasl_mutex_lock, ldap_pvt_sasl_mutex_unlock, ldap_pvt_sasl_mutex_dispose ); + + ldap_pvt_thread_mutex_init( &ldap_int_sasl_mutex ); #endif if ( sasl_client_init( client_callbacks ) == SASL_OK ) { diff --git a/libraries/libldap/sasl.c b/libraries/libldap/sasl.c index e22b11ce96..12cb381663 100644 --- a/libraries/libldap/sasl.c +++ b/libraries/libldap/sasl.c @@ -37,7 +37,6 @@ #include "ldap-int.h" - /* * ldap_sasl_bind - bind to the ldap server (and X.500). * The dn (usually NULL), mechanism, and credentials are provided. @@ -417,13 +416,17 @@ ldap_sasl_interactive_bind_s( { int rc; +#if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL ) + ldap_pvt_thread_mutex_lock( &ldap_int_sasl_mutex ); +#endif + if( mechs == NULL || *mechs == '\0' ) { char *smechs; rc = ldap_pvt_sasl_getmechs( ld, &smechs ); if( rc != LDAP_SUCCESS ) { - return rc; + goto done; } Debug( LDAP_DEBUG_TRACE, @@ -442,5 +445,10 @@ ldap_sasl_interactive_bind_s( serverControls, clientControls, flags, interact, defaults ); +done: +#if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL ) + ldap_pvt_thread_mutex_unlock( &ldap_int_sasl_mutex ); +#endif + return rc; } -- GitLab