* 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:
Corinna Vinschen
2013-07-23 14:15:20 +00:00
parent 6c1f4d7d64
commit 16efa64721
4 changed files with 74 additions and 27 deletions

View File

@@ -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 ();