GNOME Bugzilla – Bug 326576
possible race in set_state
Last modified: 2006-02-08 17:28:03 UTC
after performing an async state change, the _STATE_RETURN value is updated after taking the object lock protecting that variable. The problem is that there is a window where the state could be commited asynchronously before we update the value in which case we override the STATE_RETURN with a wrong value. A _get_state would then wait forever.
Created attachment 57150 [details] [review] proposed patch This patch sets the _STATE_RETURN to ASYNC before performing the state change to mark that we are busy. We have to be careful that we don't override the old RETURN_VALUE if there is no state change to be performed.
This sounds about right but it scares me a bit. Is there any way you could implement a test suite? Perhaps with a fake element that changes state async, spawning a thread that immediately commits the state, changing state 100 times or so. Dunno though -- "Use your best judgement" ;)
commited and closed, it's theoretically more correct and a testcase other than adding g_usleep() in places is not possible.