diff options
Diffstat (limited to 'winsup/cygwin/sync.cc')
-rw-r--r-- | winsup/cygwin/sync.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/winsup/cygwin/sync.cc b/winsup/cygwin/sync.cc index b6dec83fa..dbc26304b 100644 --- a/winsup/cygwin/sync.cc +++ b/winsup/cygwin/sync.cc @@ -23,10 +23,10 @@ details. */ #include "sync.h" #include "security.h" -muto NO_COPY muto_start; - #undef WaitForSingleObject +DWORD NO_COPY muto::exiting_thread; + /* Constructor */ muto * muto::init (const char *s) @@ -40,8 +40,6 @@ muto::init (const char *s) return NULL; } name = s; - next = muto_start.next; - muto_start.next = this; return this; } @@ -71,6 +69,8 @@ int muto::acquire (DWORD ms) { DWORD this_tid = GetCurrentThreadId (); + if (exiting_thread) + return this_tid == exiting_thread; if (tid != this_tid) { @@ -113,6 +113,8 @@ int muto::release () { DWORD this_tid = GetCurrentThreadId (); + if (exiting_thread) + return this_tid == exiting_thread; if (tid != this_tid || !visits) { @@ -135,6 +137,12 @@ muto::release () return 1; /* success. */ } +bool +muto::acquired () +{ + return tid == GetCurrentThreadId (); +} + /* Call only when we're exiting. This is not thread safe. */ void muto::reset () |