Wrap strtok use with mutex.

This commit is contained in:
Kurt Zeilenga 1999-01-01 20:43:29 +00:00
parent a5e6fa0d1c
commit ad8a5146a6
4 changed files with 9 additions and 0 deletions

View 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 );

View 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 );

View 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;

View 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;