The Microsoft documentation is silent about what happens if I mistakenly call ReleaseMutex()
when the mutex is already unlocked.
Details:
I'm trying to fix up some Windows code without having access to the compiler.
I realise that WinApi mutexes are all recursive, and reference-counted. If I were making use of that feature, it's obvious that the extra ReleaseMutex()
call would prematurely decrement the reference counter.
However, the code that I am looking at does not use the mutex recursively, so the reference count never gets higher than '1'. It does release the mutex more times than necessary... so what happens? Does the reference count go negative? Does it stay at zero (unlocked) and just return an ignorable error?
(Naturally, this code doesn't actually check for errors when it calls these functions!)