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>2002-10-14 07:51:44 +0400
committerChristopher Faylor <me@cgf.cx>2002-10-14 07:51:44 +0400
commit969203ce911a958c9b41ab934334c48bd15df7e0 (patch)
tree498582ade58561d078daad2659014646941ade0c
parenta7a5d0ba3742911e0ab9dfeed077631f25bb257f (diff)
* cygthread.cc (cygthread::stub): Reintroduce clearing of __name but do it
before SetEvent to eliminate a race. (cygthread::terminate): Accumulate list of threads to check for termination and call WaitForMultipleObjects on list rather than waiting for each thread individually. * sigproc.cc (subproc_init): Zap hwait_subproc thread handle since it is no longer used. * spawn.cc (spawn_guts): Fix so that cygthread::terminate is *really* called only for exec.
-rw-r--r--winsup/cygwin/ChangeLog15
-rw-r--r--winsup/cygwin/cygthread.cc15
-rw-r--r--winsup/cygwin/sigproc.cc3
-rw-r--r--winsup/cygwin/spawn.cc6
4 files changed, 31 insertions, 8 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 8eb5d9367..f9c2b8943 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,20 @@
2002-10-13 Christopher Faylor <cgf@redhat.com>
+ * cygthread.cc (cygthread::stub): Reintroduce clearing of __name but do
+ it before SetEvent to eliminate a race.
+ (cygthread::terminate): Accumulate list of threads to check for
+ termination and call WaitForMultipleObjects on list rather than waiting
+ for each thread individually.
+ * sigproc.cc (subproc_init): Zap hwait_subproc thread handle since it
+ is no longer used.
+
+2002-10-13 Christopher Faylor <cgf@redhat.com>
+
+ * spawn.cc (spawn_guts): Fix so that cygthread::terminate is *really*
+ called only for exec.
+
+2002-10-13 Christopher Faylor <cgf@redhat.com>
+
* cygthread.cc (cygthread::stub): Don't zero __name here. That
introduces a race.
diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc
index ce64a746c..d4295e61b 100644
--- a/winsup/cygwin/cygthread.cc
+++ b/winsup/cygwin/cygthread.cc
@@ -58,6 +58,7 @@ cygthread::stub (VOID *arg)
#ifdef DEBUGGING
info->func = NULL; // catch erroneous activation
#endif
+ info->__name = NULL;
SetEvent (info->ev);
}
switch (WaitForSingleObject (info->thread_sync, INFINITE))
@@ -313,15 +314,19 @@ cygthread::terminate ()
(void) TerminateThread (runner_handle, 0);
(void) WaitForSingleObject (runner_handle, INFINITE);
(void) CloseHandle (runner_handle);
+ HANDLE hthreads[NTHREADS];
+ int n = 0;
for (unsigned i = 0; i < NTHREADS; i++)
if (threads[i].h)
{
+ hthreads[n++] = threads[i].h;
TerminateThread (threads[i].h, 0);
- (void) WaitForSingleObject (threads[i].h, INFINITE);
- (void) CloseHandle (threads[i].h);
-#ifdef DEBUGGING
- threads[i].h = NULL;
-#endif
}
+ if (n)
+ {
+ (void) WaitForMultipleObjects (n, hthreads, TRUE, INFINITE);
+ while (--n >= 0)
+ CloseHandle (hthreads[n]);
+ }
}
}
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index db5626b89..863a22d36 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -805,8 +805,9 @@ subproc_init (void)
*/
events[0] = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
hwait_subproc = new cygthread (wait_subproc, NULL, "proc");
+ hwait_subproc->zap_h ();
ProtectHandle (events[0]);
- sigproc_printf ("started wait_subproc thread %p", (HANDLE) *hwait_subproc);
+ sigproc_printf ("started wait_subproc thread");
}
/* Initialize some of the memory block passed to child processes
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index b3bf304fb..6bc76fba3 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -715,8 +715,10 @@ spawn_guts (const char * prog_arg, const char *const *argv,
cygheap->fdtab.fixup_before_exec (pi.dwProcessId);
cygheap_setup_for_child_cleanup (newheap, &ciresrv, 1);
if (mode == _P_OVERLAY)
- ResumeThread (pi.hThread);
- cygthread::terminate ();
+ {
+ ResumeThread (pi.hThread);
+ cygthread::terminate ();
+ }
}
if (mode != _P_OVERLAY)