From 332600d80cdfcf46ce36c9f5c77b452d8636fa7f Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 15 Mar 2000 04:49:36 +0000 Subject: Pipe changes throughout suggested by Eric Fifer * debug.cc (threadname_init): Pass name of lock as arg 2 of new_muto. * malloc.cc (malloc_init): Ditto. * sigproc.cc (sigproc_init): Ditto. * exceptions.cc (events_init): Ditto. (call_handler): Eliminate special case for hExeced. Report locked thread in debugging output. * fhandler.cc (fhandker_pipe::fhandler_pipe): Propagate device type to base class. * fhandler.h (fhandler_pipe): Ditto. * hinfo.cc (hinfo::build_fhandler): Pass specific type of pipe to constructor. * spawn.cc (spawn_guts): Eliminate dependency on signal when waiting for subprocess. * strace.cc: Remove obsolete #ifdef. * sync.cc (muto::muto): Save the name of the muto. (muto:~muto): Also release the muto. * sync.h: Add a muto name field. * select.cc (peek_pipe): Avoid doing a PeekNamedPipe on the write end of a pipe. --- winsup/cygwin/sync.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'winsup/cygwin/sync.cc') diff --git a/winsup/cygwin/sync.cc b/winsup/cygwin/sync.cc index aa3978fe0..31bb27bdc 100644 --- a/winsup/cygwin/sync.cc +++ b/winsup/cygwin/sync.cc @@ -25,7 +25,7 @@ details. */ muto NO_COPY muto_start; /* Constructor */ -muto::muto(int inh, const char *name) : sync (0), visits(0), waiters(-1), tid (0), next (NULL) +muto::muto(int inh, const char *s) : sync (0), visits(0), waiters(-1), tid (0), next (NULL) { /* Create event which is used in the fallback case when blocking is necessary */ if (!(bruteforce = CreateEvent (inh ? &sec_all_nih : &sec_none_nih, FALSE, FALSE, name))) @@ -34,14 +34,20 @@ muto::muto(int inh, const char *name) : sync (0), visits(0), waiters(-1), tid (0 SetLastError (oerr); return; } + name = s; } -/* Destructor */ +/* Destructor (racy?) */ muto::~muto () { + while (visits) + release (); + + HANDLE h = bruteforce; + h = NULL; /* Just need to close the event handle */ - if (bruteforce) - CloseHandle (bruteforce); + if (h) + CloseHandle (h); } /* Acquire the lock. Argument is the number of milliseconds to wait for -- cgit v1.2.3