[Libreoffice] Mutex(Guard) ignores failure to create/acquire Mutex

Tor Lillqvist tlillqvist at novell.com
Fri Aug 19 02:06:23 PDT 2011


> EnterCriticalSection does not return a value... it is recursive but
> the doc does not mention any limit (and since Windows is not open
> source, I cannot go and look in the source code to find out what the
> limit is)

Well, if you just look at the definition of CRITICAL_SECTION in winbase.h (for MinGW) or definition of RTL_CRITICAL_SECTION in WinNT.h (for the Windows SDK) you see LONG RecursionCount, and in the Windows API LONG is a 32-bit integer (both in 32- and 64-bit code).

> an error _can_ occur, but you cannot test for it, because the function
> return void.... ahh Windows :-)

Well, just as we deliberately ignore rare errors in our code here, presumably there is a good reason for this, too. (But yeah. more likely just laziness and API stability concerns.)

Anyway, CRITICAL_SECTION contains a HANDLE OwningThread field that presumably can be used to check for this. Also, there is another struct with "debugging" information associated with each CRITICAL_SECTION, which contains information that can apparently be used for more thorough checking of critical section usage in a debugging build of software.

--tml




More information about the LibreOffice mailing list