diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c5b2d3590..bb59e87e4 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2002-11-14 Christopher Faylor + + * exceptions.cc (setup_handler): Add debugging output. Set thread + priority to idle if pending signals to allow other threads to get into + interruptible state. + * miscfuncs.cc (sys_mbstowcs): Save current thread in variable to avoid + an OS call. + * wait.cc (wait_sig): Reset thread priority each time through loop + since the priority may have been set down to deal with pending signals. + 2002-11-14 Christopher Faylor * fhandler_serial.cc (fhandler_serial::tcgetattr): Don't take any diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 05f285b2e..ae868cc7c 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -637,7 +637,7 @@ interruptible (DWORD pc, int testvalid = 0) # define h ((HMODULE) m.AllocationBase) /* Apparently Windows 95 can sometimes return bogus addresses from - GetThreadContext. These resolve to an allocation base == 0. + GetThreadContext. These resolve to a strange allocation base. These should *never* be treated as interruptible. */ if (!h || m.State != MEM_COMMIT) res = 0; @@ -866,7 +866,13 @@ setup_handler (int sig, void *handler, struct sigaction& siga) LeaveCriticalSection (&th->lock); } else if (interruptible (cx.Eip)) - interrupted = interrupt_now (&cx, sig, handler, siga); + { + interrupted = interrupt_now (&cx, sig, handler, siga); +#ifdef DEBUGGING + if (!interrupted) + sigproc_printf ("couldn't deliver signal %d via %p", sig, cx.Eip); +#endif + } else break; } @@ -892,6 +898,8 @@ setup_handler (int sig, void *handler, struct sigaction& siga) } sigproc_printf ("returning %d", interrupted); + if (pending_signals) + SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE); return interrupted; } #endif /* i386 */ diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index c8b8ee981..70e719915 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -1556,9 +1556,7 @@ fhandler_console::write (const void *vsrc, size_t len) src++; } else if (isalpha (*src)) - { - dev_state->state_ = gotcommand; - } + dev_state->state_ = gotcommand; else if (*src != '@' && !isalpha (*src) && !isdigit (*src)) { if (*src == '?') diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index 36a3d9332..9c7ab5434 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -1,6 +1,6 @@ /* miscfuncs.cc: misc funcs that don't belong anywhere else - Copyright 1996, 1997, 1998, 1999, 2000 Red Hat, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. This file is part of Cygwin. @@ -295,8 +295,9 @@ sys_mbstowcs (WCHAR *tgt, const char *src, int len) void __stdcall low_priority_sleep (DWORD secs) { - DWORD prio = GetThreadPriority (GetCurrentThread ()); - SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE); + HANDLE thisthread = GetCurrentThread (); + int curr_prio = GetThreadPriority (thisthread); + SetThreadPriority (thisthread, THREAD_PRIORITY_IDLE); Sleep (secs); - SetThreadPriority (GetCurrentThread (), prio); + SetThreadPriority (thisthread, curr_prio); } diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index af59a67ff..5f4d4c07a 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -1096,6 +1096,7 @@ wait_sig (VOID *self) for (;;) { DWORD rc = WaitForMultipleObjects (3, catchem, FALSE, sig_loop_wait); + (void) SetThreadPriority (GetCurrentThread (), WAIT_SIG_PRIORITY); /* sigproc_terminate sets sig_loop_wait to zero to indicate that * this thread should terminate.