* ntdll.h (struct _SEMAPHORE_BASIC_INFORMATION): Define.
(enum _SEMAPHORE_INFORMATION_CLASS): Define. (NtQuerySemaphore): Declare. * thread.h (class semaphore): Add member startvalue. (semaphore::fixup_before_fork): New inline method. (semaphore::_fixup_before_fork): Declare. * thread.cc (MTinterface::fixup_before_fork): Additionally call semaphore::fixup_before_fork. (semaphore::semaphore): Set currentvalue to -1. Set startvalue to incoming initializer value. (semaphore::_getvalue): Just query semaphore using NtQuerySemaphore rather then using WFSO/Release. (semaphore::_post): Drop setting currentvalue. It's not thread-safe. (semaphore::_trywait): Ditto. (semaphore::_timedwait): Ditto. (semaphore::_wait): Ditto. (semaphore::_fixup_before_fork): New method, setting currentvalue from actual windows semaphore right before fork. (semaphore::_fixup_after_fork): Drop kludge from 2013-07-10. Drop FIXME comment.
This commit is contained in:
@@ -638,6 +638,7 @@ public:
|
||||
HANDLE win32_obj_id;
|
||||
int shared;
|
||||
LONG currentvalue;
|
||||
LONG startvalue;
|
||||
int fd;
|
||||
unsigned long long hash;
|
||||
LUID luid;
|
||||
@@ -648,6 +649,10 @@ public:
|
||||
~semaphore ();
|
||||
|
||||
class semaphore * next;
|
||||
static void fixup_before_fork ()
|
||||
{
|
||||
semaphores.for_each (&semaphore::_fixup_before_fork);
|
||||
}
|
||||
static void fixup_after_fork ()
|
||||
{
|
||||
semaphores.fixup_after_fork ();
|
||||
@@ -666,6 +671,7 @@ private:
|
||||
int _trywait ();
|
||||
int _timedwait (const struct timespec *abstime);
|
||||
|
||||
void _fixup_before_fork ();
|
||||
void _fixup_after_fork ();
|
||||
void _terminate ();
|
||||
|
||||
|
Reference in New Issue
Block a user