winxp threads: detect SRWLock emulation reentrancy
authorRyan Lortie <desrt@desrt.ca>
Mon, 26 Sep 2011 08:44:41 +0000 (04:44 -0400)
committerRyan Lortie <desrt@desrt.ca>
Mon, 26 Sep 2011 12:54:51 +0000 (08:54 -0400)
commitfdc594e963b52b1b554fbbc522b91937a39bb5dc
tree16479ffa8e60b092f4ec7ccaa9dfe2b2ccfd8b50
parent5ef7b964e5d7022c9ecc6b75b2a670e407c18698
winxp threads: detect SRWLock emulation reentrancy

We lack SRWLock on Windows XP, so we use CRITICAL_SECTION to emulate it
there.  SRWLock is non-recursive, but CRITICAL_SECTION will happily
allow itself to be acquired multiple times by the same thread.

We need to detect if our second acquire succeeded because of the
recursive nature of CRITICAL_SECTION.  In the case of a _lock()
operation, we would normally have deadlocked, so abort.  In the case of
a _trylock() operation, we need to ensure that FALSE is properly
returned.

Problem caught by Matthias Clasen and Chun-wei Fan.

https://bugzilla.gnome.org/show_bug.cgi?id=660096
glib/gthread-win32.c