[Bf-blender-cvs] [794311c92bb] master: Cycles: Fix race condition happening in progress utility

Sergey Sharybin noreply at git.blender.org
Fri Jun 16 10:25:24 CEST 2017


Commit: 794311c92bb2fb7544a8fd5f9d911589a805642b
Author: Sergey Sharybin
Date:   Fri Jun 16 10:22:35 2017 +0200
Branches: master
https://developer.blender.org/rB794311c92bb2fb7544a8fd5f9d911589a805642b

Cycles: Fix race condition happening in progress utility

This is not enough to mutex-guard modification code of integer values,
since this operation is NOT atomic. This is not even safe for a single
byte data types.

For now guarded the getter functions, similar to other functions in
this module.

Ideally we want to switch modification to an atomic operations, so we
wouldn't need any locks in the getters.

===================================================================

M	intern/cycles/util/util_progress.h

===================================================================

diff --git a/intern/cycles/util/util_progress.h b/intern/cycles/util/util_progress.h
index bc672669e1f..cd4fe52fdc9 100644
--- a/intern/cycles/util/util_progress.h
+++ b/intern/cycles/util/util_progress.h
@@ -226,6 +226,7 @@ public:
 
 	int get_current_sample()
 	{
+		thread_scoped_lock lock(progress_mutex);
 		/* Note that the value here always belongs to the last tile that updated,
 		 * so it's only useful if there is only one active tile. */
 		return current_tile_sample;
@@ -233,11 +234,13 @@ public:
 
 	int get_rendered_tiles()
 	{
+		thread_scoped_lock lock(progress_mutex);
 		return rendered_tiles;
 	}
 
 	int get_denoised_tiles()
 	{
+		thread_scoped_lock lock(progress_mutex);
 		return denoised_tiles;
 	}




More information about the Bf-blender-cvs mailing list