void (*fn)(void *private_data), void *private_data)
{
int res;
+ int unlock_res;
res = pthread_mutex_lock(&pool->mutex);
if (res != 0) {
* Protect against the pool being shut down while
* trying to add a job
*/
- res = pthread_mutex_unlock(&pool->mutex);
- assert(res == 0);
+ unlock_res = pthread_mutex_unlock(&pool->mutex);
+ assert(unlock_res == 0);
return EINVAL;
}
* Add job to the end of the queue
*/
if (!pthreadpool_put_job(pool, job_id, fn, private_data)) {
- res = pthread_mutex_unlock(&pool->mutex);
- assert(res == 0);
+ unlock_res = pthread_mutex_unlock(&pool->mutex);
+ assert(unlock_res == 0);
return ENOMEM;
}
if (pool->num_idle > 0) {
- int unlock_res;
/*
* We have idle threads, wake one.
*/
/*
* No more new threads, we just queue the request
*/
- res = pthread_mutex_unlock(&pool->mutex);
- assert(res == 0);
+ unlock_res = pthread_mutex_unlock(&pool->mutex);
+ assert(unlock_res == 0);
return 0;
}
res = pthreadpool_create_thread(pool);
if (res == 0) {
- res = pthread_mutex_unlock(&pool->mutex);
- assert(res == 0);
+ unlock_res = pthread_mutex_unlock(&pool->mutex);
+ assert(unlock_res == 0);
return 0;
}
* At least one thread is still available, let
* that one run the queued job.
*/
- res = pthread_mutex_unlock(&pool->mutex);
- assert(res == 0);
+ unlock_res = pthread_mutex_unlock(&pool->mutex);
+ assert(unlock_res == 0);
return 0;
}
*/
pthreadpool_undo_put_job(pool);
- res = pthread_mutex_unlock(&pool->mutex);
- assert(res == 0);
+ unlock_res = pthread_mutex_unlock(&pool->mutex);
+ assert(unlock_res == 0);
fn(private_data);
res = pool->signal_fn(job_id, fn, private_data,