* cygthread.cc (cygthread::initialized): Avoid copying on fork or some threads
may not end up in the pool. (cygthread::new): Avoid race when checking for initialized. Add debugging code. * fhandler.cc (fhandler_base::raw_read): Add case for ERROR_INVALID_HANDLE due to Win95 directories. (fhandler_base::open): Handle errors due to Win95 directories. (fhandler_base::close): Add get_nohandle () test. (fhandler_base::set_close_on_exec): Ditto. (fhandler_base::fork_fixup): Ditto. (fhandler_base::lock): Change error code to Posix EINVAL. (fhandler_base::dup): If get_nohandle (), set new value to INVALID_HANDLE_VALUE instead of NULL. * fhandler_disk_file.cc (fhandler_disk_file::fstat): Call fstat_by_name if get_nohandle (). Remove extraneous element from strpbrk. (fhandler_disk_file::open): Remove test for Win95 directory. * fhandler_random.cc (fhandler_dev_random::open): Add set_nohandle (). * fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto. * fhandler_zero.cc (fhandler_dev_zero::open): Ditto. (fhandler_dev_zero::close): Delete. * fhandler.h (class fhandler_dev_zero): Ditto.
This commit is contained in:
@@ -19,7 +19,7 @@ static cygthread NO_COPY threads[6];
|
||||
#define NTHREADS (sizeof (threads) / sizeof (threads[0]))
|
||||
|
||||
DWORD NO_COPY cygthread::main_thread_id;
|
||||
bool cygthread::initialized;
|
||||
bool NO_COPY cygthread::initialized;
|
||||
|
||||
/* Initial stub called by cygthread constructor. Performs initial
|
||||
per-thread initialization and loops waiting for new thread functions
|
||||
@@ -127,8 +127,9 @@ new (size_t)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
bool was_initialized = initialized;
|
||||
/* Search the threads array for an empty slot to use */
|
||||
for (info = threads; info < threads + NTHREADS; info++)
|
||||
for (info = threads + NTHREADS - 1; info >= threads; info--)
|
||||
if ((id = (DWORD) InterlockedExchange ((LPLONG) &info->avail, 0)))
|
||||
{
|
||||
info->id = id;
|
||||
@@ -139,10 +140,17 @@ new (size_t)
|
||||
return info;
|
||||
}
|
||||
|
||||
if (!initialized)
|
||||
Sleep (0); /* thread_runner is not be finished yet. */
|
||||
if (!was_initialized)
|
||||
Sleep (0); /* thread_runner is not finished yet. */
|
||||
else
|
||||
return freerange ();
|
||||
{
|
||||
#ifdef DEBUGGING
|
||||
char buf[1024];
|
||||
if (GetEnvironmentVariable ("CYGWIN_NOFREERANGE", buf, sizeof (buf)))
|
||||
api_fatal ("Overflowed cygwin thread pool");
|
||||
#endif
|
||||
return freerange ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user