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
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2013-06-08 18:38:20 +0400
committerChristopher Faylor <me@cgf.cx>2013-06-08 18:38:20 +0400
commit5d35299e5102d92a995cf5aabd0fafa5b96a2c90 (patch)
tree56ada404b775552c88ade4f86a1a2349bd8a3310 /winsup
parentebf488e1abc9737ae4aca292509f5824aa00080a (diff)
* cygwait.cc (cygwait): Remove lock around sig retrieval since this code is
essentially guarded by thread-specific signal_arrived. * exceptions.cc (_cygtls::handle_SIGCONT): Simplify. Eliminate lock/unlock since code is guarded by signal_arrived.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/cygwait.cc2
-rw-r--r--winsup/cygwin/exceptions.cc54
-rw-r--r--winsup/cygwin/fhandler_tty.cc5
-rw-r--r--winsup/cygwin/miscfuncs.cc6
5 files changed, 35 insertions, 39 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index c52534efa..992d5a7ef 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,10 @@
+2013-06-08 Christopher Faylor <me.cygwin2013@cgf.cx>
+
+ * cygwait.cc (cygwait): Remove lock around sig retrieval since this
+ code is essentially guarded by thread-specific signal_arrived.
+ * exceptions.cc (_cygtls::handle_SIGCONT): Simplify. Eliminate
+ lock/unlock since code is guarded by signal_arrived.
+
2013-06-07 Corinna Vinschen <corinna@vinschen.de>
* winver.rc (LegalCopyright): Belatedly bump to 2013.
diff --git a/winsup/cygwin/cygwait.cc b/winsup/cygwin/cygwait.cc
index fcf31b39b..b6bffa27f 100644
--- a/winsup/cygwin/cygwait.cc
+++ b/winsup/cygwin/cygwait.cc
@@ -81,11 +81,9 @@ cygwait (HANDLE object, PLARGE_INTEGER timeout, unsigned mask)
/* all set */;
else
{
- _my_tls.lock ();
int sig = _my_tls.sig;
if (is_cw_sig_cont && sig == SIGCONT)
_my_tls.sig = 0;
- _my_tls.unlock ();
if (!sig)
continue;
if (is_cw_sig_eintr || (is_cw_sig_cont && sig == SIGCONT))
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 2fd75c65a..ac13478c3 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -1252,38 +1252,28 @@ signal_exit (int sig, siginfo_t *si)
void
_cygtls::handle_SIGCONT ()
{
- if (ISSTATE (myself, PID_STOPPED))
- {
- myself->stopsig = 0;
- myself->process_state &= ~PID_STOPPED;
- int state = 0;
- /* Carefully tell sig_handle_tty_stop to wake up.
- Make sure that any pending signal is handled before trying to
- send a new one. Then make sure that SIGCONT has been recognized
- before exiting the loop. */
- while (state < 2)
- {
- lock ();
- bool do_yield = !!sig;
- if (do_yield)
- /* signal still being processed */;
- else if (state)
- state++; /* state == 2: signal no longer being processed */
- else
- {
- sig = SIGCONT;
- SetEvent (signal_arrived);
- state++; /* state == 1: alert sig_handle_tty_stop */
- do_yield = true; /* wake up other thread */
- }
- unlock ();
- if (do_yield)
- yield ();
- }
- /* Tell wait_sig to handle any queued signals now that we're alive
- again. */
- sig_dispatch_pending (false);
- }
+ if (NOTSTATE (myself, PID_STOPPED))
+ return;
+
+ myself->stopsig = 0;
+ myself->process_state &= ~PID_STOPPED;
+ /* Carefully tell sig_handle_tty_stop to wake up.
+ Make sure that any pending signal is handled before trying to
+ send a new one. Then make sure that SIGCONT has been recognized
+ before exiting the loop. */
+ bool sigsent = false;
+ while (1)
+ if (sig) /* Assume that it's ok to just test sig outside of a
+ lock since setup_handler does it this way. */
+ yield (); /* Attempt to schedule another thread. */
+ else if (sigsent)
+ break; /* SIGCONT has been recognized by other thread */
+ else
+ {
+ sig = SIGCONT;
+ SetEvent (signal_arrived); /* alert sig_handle_tty_stop */
+ sigsent = true;
+ }
/* Clear pending stop signals */
sig_clear (SIGSTOP);
sig_clear (SIGTSTP);
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 34c879503..5efbf4328 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -96,7 +96,7 @@ fhandler_pty_common::__acquire_output_mutex (const char *fn, int ln,
{
if (strace.active ())
strace.prntf (_STRACE_TERMIOS, fn, "(%d): pty output_mutex (%p): waiting %d ms", ln, output_mutex, ms);
- if (ms == INFINITE)
+ if (0 && ms == INFINITE)
ms = 100;
DWORD res = WaitForSingleObject (output_mutex, ms);
if (res == WAIT_OBJECT_0)
@@ -145,6 +145,9 @@ fhandler_pty_common::__release_output_mutex (const char *fn, int ln)
void
fhandler_pty_master::doecho (const void *str, DWORD len)
{
+ static char buf[128 * 1024];
+ int buflen = process_slave_output (buf, sizeof (buf), false);
+ puts_readahead (buf, buflen);
acquire_output_mutex (INFINITE);
if (!WriteFile (to_master, str, len, &len, NULL))
termios_printf ("Write to %p failed, %E", to_master);
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index d0748ea6c..c2b405eed 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -251,10 +251,8 @@ yield ()
/* MSDN implies that SleepEx will force scheduling of other threads.
Unlike SwitchToThread() the documentation does not mention other
cpus so, presumably (hah!), this + using a lower priority will
- stall this thread temporarily and cause another to run.
- Note: Don't use 0 timeout. This takes a lot of CPU if something
- goes wrong. */
- SleepEx (1L, false);
+ stall this thread temporarily and cause another to run. */
+ SleepEx (0L, false);
}
SetThreadPriority (GetCurrentThread (), prio);
}