Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-03-08 08:05:02 +0300
committerChristopher Faylor <me@cgf.cx>2005-03-08 08:05:02 +0300
commit18edcecfbf74f23bffeefcaca1722407f6a9f597 (patch)
tree659de52828393063ae25a9e158cef9a516bf2cd1 /winsup/cygwin/sync.cc
parent453456187764ae9cd1911693bf4d68e85898b9cf (diff)
* dcrt0.cc (dll_crt0_0): Eliminate muto::init call.
* sync.h (locker): New, currently unused class. (muto::init): Eliminate. * sync.cc (muto::init): Ditto. (muto::init): Eliminate critical section lock and instead use name as a guard to prevent against multiple attempts to initialize the same muto. * pinfo.cc (pinfo::init): Set myself procinfo when not execing and pid matches windows pid or cygwin pid.
Diffstat (limited to 'winsup/cygwin/sync.cc')
-rw-r--r--winsup/cygwin/sync.cc28
1 files changed, 9 insertions, 19 deletions
diff --git a/winsup/cygwin/sync.cc b/winsup/cygwin/sync.cc
index f946bc705..20995da2d 100644
--- a/winsup/cygwin/sync.cc
+++ b/winsup/cygwin/sync.cc
@@ -31,12 +31,6 @@ DWORD NO_COPY muto::exiting_thread;
CRITICAL_SECTION NO_COPY muto::init_lock;
void
-muto::init ()
-{
- InitializeCriticalSection (&init_lock);
-}
-
-void
muto::grab ()
{
tls = &_my_tls;
@@ -46,23 +40,19 @@ muto::grab ()
muto *
muto::init (const char *s)
{
- muto *res = this;
- EnterCriticalSection (&init_lock);
- if (!bruteforce)
+ char *already_exists = (char *) InterlockedExchangePointer (&name, s);
+ if (already_exists)
+ while (!bruteforce)
+ low_priority_sleep (0);
+ else
{
waiters = -1;
- bruteforce = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
/* Create event which is used in the fallback case when blocking is necessary */
- if (bruteforce)
- name = s;
- else
- {
- DWORD oerr = GetLastError ();
- SetLastError (oerr);
- res = NULL;
- }
+ bruteforce = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
+ if (!bruteforce)
+ api_fatal ("couldn't allocate muto '%s', %E", s);
}
- LeaveCriticalSection (&init_lock);
+
return this;
}