Commit fc49135a authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Import unprotected strtok fix from -devel. Yes, you have to edit 8 files

to add a simple mutex.  Should be two (proto-slap.h & init.c).
parent 2532c072
......@@ -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( &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 );
......
......@@ -36,6 +36,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;
......
......@@ -241,6 +241,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;
......
......@@ -49,6 +49,7 @@ pthread_mutex_t entry2str_mutex;
pthread_mutex_t active_threads_mutex;
pthread_mutex_t new_conn_mutex;
pthread_mutex_t currenttime_mutex;
pthread_mutex_t strtok_mutex;
pthread_mutex_t replog_mutex;
pthread_mutex_t ops_mutex;
pthread_mutex_t regex_mutex;
......
......@@ -31,6 +31,7 @@ pthread_mutex_t entry2str_mutex;
pthread_mutex_t active_threads_mutex;
pthread_mutex_t new_conn_mutex;
pthread_mutex_t currenttime_mutex;
pthread_mutex_t strtok_mutex;
pthread_mutex_t replog_mutex;
pthread_mutex_t ops_mutex;
pthread_mutex_t regex_mutex;
......
......@@ -28,6 +28,7 @@ pthread_mutex_t entry2str_mutex;
pthread_mutex_t active_threads_mutex;
pthread_mutex_t new_conn_mutex;
pthread_mutex_t currenttime_mutex;
pthread_mutex_t strtok_mutex;
pthread_mutex_t replog_mutex;
pthread_mutex_t ops_mutex;
pthread_mutex_t regex_mutex;
......
......@@ -30,6 +30,7 @@ pthread_mutex_t entry2str_mutex;
pthread_mutex_t active_threads_mutex;
pthread_mutex_t new_conn_mutex;
pthread_mutex_t currenttime_mutex;
pthread_mutex_t strtok_mutex;
pthread_mutex_t replog_mutex;
pthread_mutex_t ops_mutex;
pthread_mutex_t regex_mutex;
......
......@@ -34,6 +34,7 @@ pthread_mutex_t entry2str_mutex;
pthread_mutex_t active_threads_mutex;
pthread_mutex_t new_conn_mutex;
pthread_mutex_t currenttime_mutex;
pthread_mutex_t strtok_mutex;
pthread_mutex_t replog_mutex;
pthread_mutex_t ops_mutex;
pthread_mutex_t regex_mutex;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment