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>2003-04-04 09:58:06 +0400
committerChristopher Faylor <me@cgf.cx>2003-04-04 09:58:06 +0400
commitb410f1680ffb26c9c3f972a2f33acc0d4e2fe30c (patch)
tree61761d463831462085e49ea3deaf304972547571 /winsup/cygwin/cygthread.cc
parenta61bf8c3693d99f90ec7e64860e8ba8c666b912c (diff)
* cygthread.cc (operator new): Be more defensive when messing with threads that
are marked "unavailable".
Diffstat (limited to 'winsup/cygwin/cygthread.cc')
-rw-r--r--winsup/cygwin/cygthread.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc
index 251fe5e3c..4ed0d52cf 100644
--- a/winsup/cygwin/cygthread.cc
+++ b/winsup/cygwin/cygthread.cc
@@ -136,7 +136,9 @@ new (size_t)
/* Search the threads array for an empty slot to use */
for (info = threads; info < threads + NTHREADS; info++)
- if ((id = (DWORD) InterlockedExchange ((LPLONG) &info->avail, 0)))
+ if ((LONG) (id = (DWORD) InterlockedExchange ((LPLONG) &info->avail, -1)) < 0)
+ /* being considered */;
+ else if (id > 0)
{
#ifdef DEBUGGING
if (info->__name)
@@ -146,7 +148,9 @@ new (size_t)
#endif
goto out;
}
- else if (!info->id)
+ else if (info->id)
+ InterlockedExchange ((LPLONG) &info->avail, 0);
+ else
{
info->h = CreateThread (&sec_none_nih, 0, cygthread::stub, info,
CREATE_SUSPENDED, &info->id);
@@ -162,6 +166,7 @@ new (size_t)
info = freerange (); /* exhausted thread pool */
out:
+ InterlockedExchange ((LPLONG) &info->avail, 0);
cygthread_protect->release ();
return info;
}