* exceptions.cc (_cygtls::call_signal_handler): Add paranoid debugging output.
* sigproc.h (cygwait): Call signal handler when signal is detected and loop as
appropriate.
* fhandler.h (fhandler_base_overlapped::wait_return): Remove overlapped_signal.
* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Remove restartable
signal accommodations in light of cygwait improvements.
(fhandler_base_overlapped::raw_read): Remove now-obsolete signal loop behavior.
(fhandler_base_overlapped::raw_write): Ditto.
* fhandler_console.cc (fhandler_console::read): Ditto.
* fhandler_serial.cc (fhandler_serial::raw_read): Ditto.
(fhandler_serial::raw_write): Ditto.
* fhandler_tty.cc (fhandler_pty_slave::read): Ditto.
* ioctl.cc (ioctl): Add standard syscall introducer and leaver debug output.
+2011-12-12 Christopher Faylor <me.cygwin2011@cgf.cx>
+
+ * cygthread.h (cygthread::name): Very minor formatting tweak.
+
+ * exceptions.cc (_cygtls::call_signal_handler): Add paranoid debugging
+ output.
+
+ * sigproc.h (cygwait): Call signal handler when signal is detected and
+ loop as appropriate.
+ * fhandler.h (fhandler_base_overlapped::wait_return): Remove
+ overlapped_signal.
+ * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Remove
+ restartable signal accommodations in light of cygwait improvements.
+ (fhandler_base_overlapped::raw_read): Remove now-obsolete signal loop
+ behavior.
+ (fhandler_base_overlapped::raw_write): Ditto.
+ * fhandler_console.cc (fhandler_console::read): Ditto.
+ * fhandler_serial.cc (fhandler_serial::raw_read): Ditto.
+ (fhandler_serial::raw_write): Ditto.
+ * fhandler_tty.cc (fhandler_pty_slave::read): Ditto.
+
+ * ioctl.cc (ioctl): Add standard syscall introducer and leaver debug
+ output.
+
2011-12-12 Corinna Vinschen <vinschen@redhat.com>
* fhandler_process.cc (dos_drive_mappings): Partially rewrite to
static DWORD WINAPI stub (VOID *);
static DWORD WINAPI simplestub (VOID *);
static DWORD main_thread_id;
- static const char * name (DWORD = 0);
+ static const char *name (DWORD = 0);
void callfunc (bool) __attribute__ ((noinline, regparm (2)));
void auto_release () {func = NULL;}
void release (bool);
_main_tls->lock ();
if (_main_tls->sig)
{
+ paranoid_printf ("Redirecting to main_tls signal %d", _main_tls->sig);
sig = _main_tls->sig;
sa_flags = _main_tls->sa_flags;
func = _main_tls->func;
res = overlapped_success; /* operation succeeded */
else if (wfres == WAIT_OBJECT_0 + 1)
{
- if (_my_tls.call_signal_handler ())
- res = overlapped_signal;
- else
- {
- err = ERROR_INVALID_AT_INTERRUPT_TIME; /* forces an EINTR below */
- debug_printf ("unhandled signal");
- res = overlapped_error;
- }
+ err = ERROR_INVALID_AT_INTERRUPT_TIME; /* forces an EINTR below */
+ debug_printf ("unhandled signal");
+ res = overlapped_error;
}
else if (nonblocking)
res = overlapped_nonblocking_no_data; /* more handling below */
if (res == overlapped_success)
debug_printf ("normal %s, %u bytes", writing ? "write" : "read", *bytes);
- else if (res == overlapped_signal)
- debug_printf ("handled signal");
else if (res == overlapped_nonblocking_no_data)
{
*bytes = (DWORD) -1;
get_overlapped ());
switch (wait_overlapped (res, false, &nbytes, is_nonblocking ()))
{
- case overlapped_signal:
- keep_looping = true;
- break;
default: /* Added to quiet gcc */
case overlapped_success:
case overlapped_error:
ptr = ((char *) ptr) + chunk;
nbytes += nbytes_now;
/* fall through intentionally */
- case overlapped_signal:
- break; /* keep looping */
case overlapped_error:
len = 0; /* terminate loop */
case overlapped_unknown:
{
overlapped_unknown = 0,
overlapped_success,
- overlapped_signal,
overlapped_nonblocking_no_data,
overlapped_error
};
}
set_cursor_maybe (); /* to make cursor appear on the screen immediately */
-restart:
switch (cygwait (h, timeout))
{
case WAIT_OBJECT_0:
break;
case WAIT_OBJECT_0 + 1:
- if (_my_tls.call_signal_handler ())
- goto restart;
goto sig_exit;
case WAIT_OBJECT_0 + 2:
process_state.pop ();
else
{
overlapped_armed = 1;
-restart:
switch (cygwait (io_status.hEvent))
{
case WAIT_OBJECT_0:
debug_printf ("n %d, ev %x", n, ev);
break;
case WAIT_OBJECT_0 + 1:
- if (_my_tls.call_signal_handler ())
- goto restart;
tot = -1;
PurgeComm (get_handle (), PURGE_RXABORT);
overlapped_armed = 0;
if (!is_nonblocking ())
{
- restart:
switch (cygwait (write_status.hEvent))
{
case WAIT_OBJECT_0:
break;
case WAIT_OBJECT_0 + 1:
- if (_my_tls.call_signal_handler ())
- goto restart;
PurgeComm (get_handle (), PURGE_TXABORT);
set_sig_errno (EINTR);
ForceCloseHandle (write_status.hEvent);
case WAIT_OBJECT_0 + 1:
if (totalread > 0)
goto out;
- if (_my_tls.call_signal_handler ())
- continue;
termios_printf ("wait catched signal");
set_sig_errno (EINTR);
totalread = -1;
case WAIT_OBJECT_0 + 1:
if (totalread > 0)
goto out;
- if (_my_tls.call_signal_handler ())
- continue;
termios_printf ("wait for mutex catched signal");
set_sig_errno (EINTR);
totalread = -1;
char *argp = va_arg (ap, char *);
va_end (ap);
- debug_printf ("fd %d, cmd %x", fd, cmd);
+ debug_printf ("ioctl(fd %d, cmd %p)", fd, cmd);
int res;
/* FIXME: This stinks. There are collisions between cmd types
depending on whether fd is associated with a pty master or not.
res = cfd->ioctl (cmd, argp);
out:
- debug_printf ("returning %d", res);
+ syscall_printf ("%R = ioctl(%d, %p, ...)", res, fd, cmd);
return res;
}
cygwait (HANDLE h, DWORD howlong = INFINITE)
{
HANDLE w4[3];
- int n = 0;
- if ((w4[n] = h) != NULL)
- n++;
+ DWORD n = 0;
+ DWORD wait_signal;
+ if ((w4[n] = h) == NULL)
+ wait_signal = WAIT_OBJECT_0 + 15; /* Arbitrary. Don't call signal
+ handler if only waiting for signal */
+ else
+ {
+ n++;
+ wait_signal = n;
+ }
w4[n++] = signal_arrived;
if ((w4[n] = pthread::get_cancel_event ()) != NULL)
n++;
- return WaitForMultipleObjects (n, w4, FALSE, howlong);
+ DWORD res;
+ while ((res = WaitForMultipleObjects (n, w4, FALSE, howlong)) == wait_signal
+ && _my_tls.call_signal_handler ())
+ continue;
+ return res;
}
static inline DWORD __attribute__ ((always_inline))