mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-22 07:39:35 -05:00
Wrap strtok use with mutex.
This commit is contained in:
parent
a5e6fa0d1c
commit
ad8a5146a6
4 changed files with 9 additions and 0 deletions
|
|
@ -128,10 +128,16 @@ str2charray( char *str, char *brkstr )
|
||||||
|
|
||||||
res = (char **) ch_malloc( (i + 1) * sizeof(char *) );
|
res = (char **) ch_malloc( (i + 1) * sizeof(char *) );
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&strtok_mutex);
|
||||||
|
|
||||||
for ( s = strtok( str, brkstr ); s != NULL; s = strtok( NULL,
|
for ( s = strtok( str, brkstr ); s != NULL; s = strtok( NULL,
|
||||||
brkstr ) ) {
|
brkstr ) ) {
|
||||||
res[i++] = ch_strdup( s );
|
res[i++] = ch_strdup( s );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&strtok_mutex);
|
||||||
|
|
||||||
res[i] = NULL;
|
res[i] = NULL;
|
||||||
|
|
||||||
free( str );
|
free( str );
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ init( void )
|
||||||
pthread_mutex_init( &active_threads_mutex, pthread_mutexattr_default );
|
pthread_mutex_init( &active_threads_mutex, pthread_mutexattr_default );
|
||||||
pthread_mutex_init( &new_conn_mutex, pthread_mutexattr_default );
|
pthread_mutex_init( &new_conn_mutex, pthread_mutexattr_default );
|
||||||
pthread_mutex_init( ¤ttime_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( &entry2str_mutex, pthread_mutexattr_default );
|
||||||
pthread_mutex_init( &replog_mutex, pthread_mutexattr_default );
|
pthread_mutex_init( &replog_mutex, pthread_mutexattr_default );
|
||||||
pthread_mutex_init( &ops_mutex, pthread_mutexattr_default );
|
pthread_mutex_init( &ops_mutex, pthread_mutexattr_default );
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ char **g_argv;
|
||||||
*/
|
*/
|
||||||
time_t currenttime;
|
time_t currenttime;
|
||||||
pthread_mutex_t currenttime_mutex;
|
pthread_mutex_t currenttime_mutex;
|
||||||
|
pthread_mutex_t strtok_mutex;
|
||||||
int active_threads;
|
int active_threads;
|
||||||
pthread_mutex_t active_threads_mutex;
|
pthread_mutex_t active_threads_mutex;
|
||||||
pthread_mutex_t new_conn_mutex;
|
pthread_mutex_t new_conn_mutex;
|
||||||
|
|
|
||||||
|
|
@ -243,6 +243,7 @@ extern long ops_completed;
|
||||||
extern long ops_initiated;
|
extern long ops_initiated;
|
||||||
extern pthread_mutex_t active_threads_mutex;
|
extern pthread_mutex_t active_threads_mutex;
|
||||||
extern pthread_mutex_t currenttime_mutex;
|
extern pthread_mutex_t currenttime_mutex;
|
||||||
|
extern pthread_mutex_t strtok_mutex;
|
||||||
extern pthread_mutex_t entry2str_mutex;
|
extern pthread_mutex_t entry2str_mutex;
|
||||||
extern pthread_mutex_t new_conn_mutex;
|
extern pthread_mutex_t new_conn_mutex;
|
||||||
extern pthread_mutex_t num_sent_mutex;
|
extern pthread_mutex_t num_sent_mutex;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue