[Bf-blender-cvs] [fd8b602] master: Fix race condition
Campbell Barton
noreply at git.blender.org
Wed Jun 3 03:06:34 CEST 2015
Commit: fd8b6021c4470fe766c456865368f9087afac500
Author: Campbell Barton
Date: Wed Jun 3 11:00:48 2015 +1000
Branches: master
https://developer.blender.org/rBfd8b6021c4470fe766c456865368f9087afac500
Fix race condition
Exposed when checking on T44871
===================================================================
M source/blender/blenlib/intern/threads.c
===================================================================
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index a404f46..5029595 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 */
More information about the Bf-blender-cvs
mailing list