Correctly handle abandoned mutexes on non-Windows platforms
authorNiklas Therning <niklas@therning.org>
Thu, 15 Sep 2016 11:39:03 +0000 (13:39 +0200)
committerNiklas Therning <niklas@therning.org>
Fri, 16 Sep 2016 09:07:38 +0000 (11:07 +0200)
commitb8fadb959acf8344ea637be6881027eea289531c
tree425ac80b524f91fa0a57b5f1353bc3f19b889cd9
parent5dcbbab04e970a139f8a5697a61686e3a4b1803e
Correctly handle abandoned mutexes on non-Windows platforms

When a thread owning a mutex doesn't release it before it exits and a second
thread tries to take it using e.g. Mutex.WaitOne() an AbandonedMutexException
should be thrown. This is what .NET and Mono on Windows does.

This commit builds on the work done in PR #2267, which modifies the Win32
emulation of WaitForSingleObjectEx(), SignalObjectAndWait() and
WaitForMultipleObjectsEx() to return WAIT_ABANDONED_0 when expected, and
updates it to the current HEAD. It also adds a few test methods to
WaitHandleTest that test that WaitHandle.WaitAny() and WaitHandle.WaitAll()
follows the .NET behaviour.
mcs/class/corlib/Test/System.Threading/MutexTest.cs
mcs/class/corlib/Test/System.Threading/WaitHandleTest.cs
mono/metadata/threads.c
mono/metadata/w32mutex-unix.c
mono/utils/w32handle.c