Opened 14 years ago
Closed 14 years ago
#3396 closed defect (fixed)
Incorrect mutex handling in msThreadInit on Windows
Reported by: | tamas | Owned by: | tamas |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | MapServer C Library | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: |
Description
In msThreadInit the core_lock mutex is created by setting initialOwner = TRUE and then a WaitForSingleObject increases the lock count additionally. In this case ReleaseMutex should be called twice in order to set the mutex to signaled state. With the current approach a second thread calling msThreadInit would definitely be locked forever. However this situation my be happen rarely and hard to reproduce.
For more information about this behaviour see the description of CreateMutex in the MSDN reference: http://msdn.microsoft.com/en-us/library/aa914601.aspx
Note:
See TracTickets
for help on using tickets.
I have corrected this in trunk (r10048).
The core_lock is only used within this function to avoid multiple threads trying to initialize the mutex list at the same time. It seems the problem introduces a subtle risk of extra threads hanging waiting for core_lock if they came into msThreadInit at the same time one thread is creating the mutex. Since this is IMHO a very rare issue I have only fixed it in trunk.