diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-06-03 04:00:48 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-06-03 04:01:44 +0300 |
commit | fd8b6021c4470fe766c456865368f9087afac500 (patch) | |
tree | 5240083bdfa4ab01d92b55ed12c649cede3bb853 | |
parent | 469c0695ac40286b4844c81f2ed1dc9963933c11 (diff) |
Fix race condition
Exposed when checking on T44871
-rw-r--r-- | source/blender/blenlib/intern/threads.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index a404f46a6e2..50295954192 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -199,6 +199,7 @@ void BLI_init_threads(ListBase *threadbase, void *(*do_thread)(void *), int tot) } } + BLI_spin_lock(&_malloc_lock); if (thread_levels == 0) { MEM_set_lock_callback(BLI_lock_malloc_thread, BLI_unlock_malloc_thread); @@ -211,6 +212,7 @@ void BLI_init_threads(ListBase *threadbase, void *(*do_thread)(void *), int tot) } thread_levels++; + BLI_spin_unlock(&_malloc_lock); } /* amount of available threads */ @@ -329,9 +331,11 @@ void BLI_end_threads(ListBase *threadbase) BLI_freelistN(threadbase); } + BLI_spin_lock(&_malloc_lock); thread_levels--; if (thread_levels == 0) MEM_set_lock_callback(NULL, NULL); + BLI_spin_unlock(&_malloc_lock); } /* System Information */ |