From bae2a2c3b2d005696895b39f6fc497fb0839331e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 2 Jul 2013 19:23:09 +0000 Subject: [PATCH] Added missing mutex lock around do_exit assignment in task scheduler Without this lock it's possible that thread_wait_pop will stuck at the point where it await for new task in the queue but in fact exit was requested already. This ended up in deadlock in some circumstances. Really random because it totally depends on timings. --- source/blender/blenlib/intern/task.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c index 5a8b00061a6..63ea315ce57 100644 --- a/source/blender/blenlib/intern/task.c +++ b/source/blender/blenlib/intern/task.c @@ -186,8 +186,10 @@ void BLI_task_scheduler_free(TaskScheduler *scheduler) Task *task; /* stop all waiting threads */ + BLI_mutex_lock(&scheduler->queue_mutex); scheduler->do_exit = true; BLI_condition_notify_all(&scheduler->queue_cond); + BLI_mutex_unlock(&scheduler->queue_mutex); /* delete threads */ if(scheduler->threads) {