From: Kurt Zeilenga Date: Fri, 1 Jan 1999 20:43:29 +0000 (+0000) Subject: Wrap strtok use with mutex. X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~823 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ad8a5146a677f3cc381d1c53bbfff55a47f3db5c;p=openldap Wrap strtok use with mutex. --- diff --git a/servers/slapd/charray.c b/servers/slapd/charray.c index c2eb56ceaa..e3974e4ac0 100644 --- a/servers/slapd/charray.c +++ b/servers/slapd/charray.c @@ -128,10 +128,16 @@ str2charray( char *str, char *brkstr ) res = (char **) ch_malloc( (i + 1) * sizeof(char *) ); i = 0; + + pthread_mutex_lock(&strtok_mutex); + for ( s = strtok( str, brkstr ); s != NULL; s = strtok( NULL, brkstr ) ) { res[i++] = ch_strdup( s ); } + + pthread_mutex_unlock(&strtok_mutex); + res[i] = NULL; free( str ); diff --git a/servers/slapd/init.c b/servers/slapd/init.c index e93479432c..5921fd59f8 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -17,6 +17,7 @@ init( void ) pthread_mutex_init( &active_threads_mutex, pthread_mutexattr_default ); pthread_mutex_init( &new_conn_mutex, pthread_mutexattr_default ); pthread_mutex_init( ¤ttime_mutex, pthread_mutexattr_default ); + pthread_mutex_init( &strtok_mutex, pthread_mutexattr_default ); pthread_mutex_init( &entry2str_mutex, pthread_mutexattr_default ); pthread_mutex_init( &replog_mutex, pthread_mutexattr_default ); pthread_mutex_init( &ops_mutex, pthread_mutexattr_default ); diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 0ffbd3c9c2..afc42a316a 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -37,6 +37,7 @@ char **g_argv; */ time_t currenttime; pthread_mutex_t currenttime_mutex; +pthread_mutex_t strtok_mutex; int active_threads; pthread_mutex_t active_threads_mutex; pthread_mutex_t new_conn_mutex; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 1bf95deb2d..7e8ce52357 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -243,6 +243,7 @@ extern long ops_completed; extern long ops_initiated; extern pthread_mutex_t active_threads_mutex; extern pthread_mutex_t currenttime_mutex; +extern pthread_mutex_t strtok_mutex; extern pthread_mutex_t entry2str_mutex; extern pthread_mutex_t new_conn_mutex; extern pthread_mutex_t num_sent_mutex;