From: Kurt Zeilenga Date: Fri, 22 Jan 1999 04:46:54 +0000 (+0000) Subject: Use strtok_r() instead of strtok(). Remove strtok mutex! X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~715 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=637c0a83011fbe8ad6de6cff82ea65a495cae6f2;p=openldap Use strtok_r() instead of strtok(). Remove strtok mutex! --- diff --git a/servers/slapd/charray.c b/servers/slapd/charray.c index e3974e4ac0..741a0e1595 100644 --- a/servers/slapd/charray.c +++ b/servers/slapd/charray.c @@ -114,6 +114,7 @@ str2charray( char *str, char *brkstr ) { char **res; char *s; + char *lasts; int i; /* protect the input string from strtok */ @@ -129,15 +130,13 @@ 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 ) ) { + for ( s = strtok_r( str, brkstr, &lasts ); + s != NULL; + s = strtok_r( NULL, brkstr, &lasts ) ) + { 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 527fe16507..f92d8bba73 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -45,7 +45,6 @@ pthread_mutex_t new_conn_mutex; #ifdef SLAPD_CRYPT pthread_mutex_t crypt_mutex; #endif -pthread_mutex_t strtok_mutex; int num_conns; long ops_initiated; @@ -70,7 +69,6 @@ init( void ) 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/proto-slap.h b/servers/slapd/proto-slap.h index cfdea5d3a6..b519ffb967 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -251,7 +251,6 @@ extern pthread_mutex_t active_threads_mutex; extern pthread_cond_t active_threads_cond; 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; diff --git a/servers/slapd/tools/centipede.c b/servers/slapd/tools/centipede.c index d8943a9201..fec0921949 100644 --- a/servers/slapd/tools/centipede.c +++ b/servers/slapd/tools/centipede.c @@ -519,8 +519,10 @@ generate_new_centroids( /* generate a word-based centroid */ } else { - for ( w = strtok( val[j], WORD_BREAKS ); w != NULL; - w = strtok( NULL, WORD_BREAKS ) ) { + char *lasts; + for ( w = strtok_r( val[j], WORD_BREAKS, &lasts ); + w != NULL; + w = strtok_r( NULL, WORD_BREAKS, &lasts ) ) { key.dptr = w; key.dsize = strlen( key.dptr ) + 1; (void) ldbm_store( ldbm[i], key, data, LDBM_INSERT );