Solved race condition that was giving segfault when adding large number of jobs while workers were reading from job queue

This commit is contained in:
Johan 2011-11-07 01:33:43 +01:00
parent 465bdb36d5
commit 093a9b7021
1 changed files with 2 additions and 0 deletions

View File

@ -137,7 +137,9 @@ int thpool_add_work(thpool_t* tp_p, void *(*function_p)(void*), void* arg_p){
newJob->arg=arg_p;
/* add job to queue */
pthread_mutex_lock(&mutex); /* LOCK */
thpool_jobqueue_add(tp_p, newJob);
pthread_mutex_unlock(&mutex); /* UNLOCK */
return 0;
}