mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-18 11:05:48 +08:00
Wrap strtok use with mutex.
This commit is contained in:
parent
a5e6fa0d1c
commit
ad8a5146a6
@ -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 );
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user