]> git.sur5r.net Git - openldap/commitdiff
Wrap strtok use with mutex.
authorKurt Zeilenga <kurt@openldap.org>
Fri, 1 Jan 1999 20:43:29 +0000 (20:43 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 1 Jan 1999 20:43:29 +0000 (20:43 +0000)
servers/slapd/charray.c
servers/slapd/init.c
servers/slapd/main.c
servers/slapd/proto-slap.h

index c2eb56ceaa06b5c57acc202d96c02be05f2a6107..e3974e4ac05662ee3758b78cefdc1d40e7ff2e20 100644 (file)
@@ -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 );
index e93479432cbb9e3e26eb9c62c5f4379f73772d85..5921fd59f85c48af1c608dddb114eed0533baec5 100644 (file)
@@ -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( &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 0ffbd3c9c2e137980b1d39749accfb4cdb2b3f8f..afc42a316ad1a53d18cb1c685bfcb536da8bedda 100644 (file)
@@ -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;
index 1bf95deb2d7597373dba2e2601750a7f152757b0..7e8ce52357292cf061df4c9968000c6b3f1d1ae0 100644 (file)
@@ -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;