securing total_threads with the mutex while destroying the processor
authorTobias Brunner <tobias@strongswan.org>
Wed, 2 Apr 2008 15:28:08 +0000 (15:28 -0000)
committerTobias Brunner <tobias@strongswan.org>
Wed, 2 Apr 2008 15:28:08 +0000 (15:28 -0000)
src/charon/processing/processor.c

index bfae7bd..e14679b 100644 (file)
@@ -193,11 +193,13 @@ static void set_threads(private_processor_t *this, u_int count)
 static void destroy(private_processor_t *this)
 {
        set_threads(this, 0);
+       pthread_mutex_lock(&this->mutex);
        while (this->total_threads > 0)
        {
                pthread_cond_broadcast(&this->condvar);
                pthread_cond_wait(&this->condvar, &this->mutex);
        }
+       pthread_mutex_unlock(&this->mutex);
        this->list->destroy_offset(this->list, offsetof(job_t, destroy));
        free(this);
 }