* 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.
This commit is contained in:
Christopher Faylor
2002-10-14 03:51:44 +00:00
parent a7a5d0ba37
commit 969203ce91
4 changed files with 31 additions and 8 deletions

View File

@@ -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]);
}
}
}