]> git.sur5r.net Git - openldap/commitdiff
Use strtok_r() instead of strtok(). Remove strtok mutex!
authorKurt Zeilenga <kurt@openldap.org>
Fri, 22 Jan 1999 04:46:54 +0000 (04:46 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 22 Jan 1999 04:46:54 +0000 (04:46 +0000)
servers/slapd/charray.c
servers/slapd/init.c
servers/slapd/proto-slap.h
servers/slapd/tools/centipede.c

index e3974e4ac05662ee3758b78cefdc1d40e7ff2e20..741a0e15954cc7c62a429a3e6c4c1fceb04c4708 100644 (file)
@@ -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 );
index 527fe165076e6af080d0ee8b5cccf517a9db7677..f92d8bba735e4d1238f41600a112d6912d2563a3 100644 (file)
@@ -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( &currenttime_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 );
index cfdea5d3a619bbce6c0f0f1ef3727d1684ed1748..b519ffb96707e22e626980f4bf87780bae210e32 100644 (file)
@@ -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;
index d8943a9201cbdfa777c880013591c151215f562c..fec09219495b18ae92b0ec3c3407cc9e5ed68245 100644 (file)
@@ -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 );