* 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.
This commit is contained in:
parent
a7ea1550ff
commit
8cb58e8566
@ -1,3 +1,27 @@
|
|||||||
|
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>
|
2011-12-12 Corinna Vinschen <vinschen@redhat.com>
|
||||||
|
|
||||||
* fhandler_process.cc (dos_drive_mappings): Partially rewrite to
|
* fhandler_process.cc (dos_drive_mappings): Partially rewrite to
|
||||||
|
@ -38,7 +38,7 @@ class cygthread
|
|||||||
static DWORD WINAPI stub (VOID *);
|
static DWORD WINAPI stub (VOID *);
|
||||||
static DWORD WINAPI simplestub (VOID *);
|
static DWORD WINAPI simplestub (VOID *);
|
||||||
static DWORD main_thread_id;
|
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 callfunc (bool) __attribute__ ((noinline, regparm (2)));
|
||||||
void auto_release () {func = NULL;}
|
void auto_release () {func = NULL;}
|
||||||
void release (bool);
|
void release (bool);
|
||||||
|
@ -1330,6 +1330,7 @@ _cygtls::call_signal_handler ()
|
|||||||
_main_tls->lock ();
|
_main_tls->lock ();
|
||||||
if (_main_tls->sig)
|
if (_main_tls->sig)
|
||||||
{
|
{
|
||||||
|
paranoid_printf ("Redirecting to main_tls signal %d", _main_tls->sig);
|
||||||
sig = _main_tls->sig;
|
sig = _main_tls->sig;
|
||||||
sa_flags = _main_tls->sa_flags;
|
sa_flags = _main_tls->sa_flags;
|
||||||
func = _main_tls->func;
|
func = _main_tls->func;
|
||||||
|
@ -1942,14 +1942,9 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
|
|||||||
res = overlapped_success; /* operation succeeded */
|
res = overlapped_success; /* operation succeeded */
|
||||||
else if (wfres == WAIT_OBJECT_0 + 1)
|
else if (wfres == WAIT_OBJECT_0 + 1)
|
||||||
{
|
{
|
||||||
if (_my_tls.call_signal_handler ())
|
err = ERROR_INVALID_AT_INTERRUPT_TIME; /* forces an EINTR below */
|
||||||
res = overlapped_signal;
|
debug_printf ("unhandled signal");
|
||||||
else
|
res = overlapped_error;
|
||||||
{
|
|
||||||
err = ERROR_INVALID_AT_INTERRUPT_TIME; /* forces an EINTR below */
|
|
||||||
debug_printf ("unhandled signal");
|
|
||||||
res = overlapped_error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (nonblocking)
|
else if (nonblocking)
|
||||||
res = overlapped_nonblocking_no_data; /* more handling below */
|
res = overlapped_nonblocking_no_data; /* more handling below */
|
||||||
@ -1964,8 +1959,6 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
|
|||||||
|
|
||||||
if (res == overlapped_success)
|
if (res == overlapped_success)
|
||||||
debug_printf ("normal %s, %u bytes", writing ? "write" : "read", *bytes);
|
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)
|
else if (res == overlapped_nonblocking_no_data)
|
||||||
{
|
{
|
||||||
*bytes = (DWORD) -1;
|
*bytes = (DWORD) -1;
|
||||||
@ -2003,9 +1996,6 @@ fhandler_base_overlapped::raw_read (void *ptr, size_t& len)
|
|||||||
get_overlapped ());
|
get_overlapped ());
|
||||||
switch (wait_overlapped (res, false, &nbytes, is_nonblocking ()))
|
switch (wait_overlapped (res, false, &nbytes, is_nonblocking ()))
|
||||||
{
|
{
|
||||||
case overlapped_signal:
|
|
||||||
keep_looping = true;
|
|
||||||
break;
|
|
||||||
default: /* Added to quiet gcc */
|
default: /* Added to quiet gcc */
|
||||||
case overlapped_success:
|
case overlapped_success:
|
||||||
case overlapped_error:
|
case overlapped_error:
|
||||||
@ -2059,8 +2049,6 @@ fhandler_base_overlapped::raw_write (const void *ptr, size_t len)
|
|||||||
ptr = ((char *) ptr) + chunk;
|
ptr = ((char *) ptr) + chunk;
|
||||||
nbytes += nbytes_now;
|
nbytes += nbytes_now;
|
||||||
/* fall through intentionally */
|
/* fall through intentionally */
|
||||||
case overlapped_signal:
|
|
||||||
break; /* keep looping */
|
|
||||||
case overlapped_error:
|
case overlapped_error:
|
||||||
len = 0; /* terminate loop */
|
len = 0; /* terminate loop */
|
||||||
case overlapped_unknown:
|
case overlapped_unknown:
|
||||||
|
@ -620,7 +620,6 @@ protected:
|
|||||||
{
|
{
|
||||||
overlapped_unknown = 0,
|
overlapped_unknown = 0,
|
||||||
overlapped_success,
|
overlapped_success,
|
||||||
overlapped_signal,
|
|
||||||
overlapped_nonblocking_no_data,
|
overlapped_nonblocking_no_data,
|
||||||
overlapped_error
|
overlapped_error
|
||||||
};
|
};
|
||||||
|
@ -347,14 +347,11 @@ fhandler_console::read (void *pv, size_t& buflen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_cursor_maybe (); /* to make cursor appear on the screen immediately */
|
set_cursor_maybe (); /* to make cursor appear on the screen immediately */
|
||||||
restart:
|
|
||||||
switch (cygwait (h, timeout))
|
switch (cygwait (h, timeout))
|
||||||
{
|
{
|
||||||
case WAIT_OBJECT_0:
|
case WAIT_OBJECT_0:
|
||||||
break;
|
break;
|
||||||
case WAIT_OBJECT_0 + 1:
|
case WAIT_OBJECT_0 + 1:
|
||||||
if (_my_tls.call_signal_handler ())
|
|
||||||
goto restart;
|
|
||||||
goto sig_exit;
|
goto sig_exit;
|
||||||
case WAIT_OBJECT_0 + 2:
|
case WAIT_OBJECT_0 + 2:
|
||||||
process_state.pop ();
|
process_state.pop ();
|
||||||
|
@ -95,7 +95,6 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
overlapped_armed = 1;
|
overlapped_armed = 1;
|
||||||
restart:
|
|
||||||
switch (cygwait (io_status.hEvent))
|
switch (cygwait (io_status.hEvent))
|
||||||
{
|
{
|
||||||
case WAIT_OBJECT_0:
|
case WAIT_OBJECT_0:
|
||||||
@ -105,8 +104,6 @@ restart:
|
|||||||
debug_printf ("n %d, ev %x", n, ev);
|
debug_printf ("n %d, ev %x", n, ev);
|
||||||
break;
|
break;
|
||||||
case WAIT_OBJECT_0 + 1:
|
case WAIT_OBJECT_0 + 1:
|
||||||
if (_my_tls.call_signal_handler ())
|
|
||||||
goto restart;
|
|
||||||
tot = -1;
|
tot = -1;
|
||||||
PurgeComm (get_handle (), PURGE_RXABORT);
|
PurgeComm (get_handle (), PURGE_RXABORT);
|
||||||
overlapped_armed = 0;
|
overlapped_armed = 0;
|
||||||
@ -202,14 +199,11 @@ fhandler_serial::raw_write (const void *ptr, size_t len)
|
|||||||
|
|
||||||
if (!is_nonblocking ())
|
if (!is_nonblocking ())
|
||||||
{
|
{
|
||||||
restart:
|
|
||||||
switch (cygwait (write_status.hEvent))
|
switch (cygwait (write_status.hEvent))
|
||||||
{
|
{
|
||||||
case WAIT_OBJECT_0:
|
case WAIT_OBJECT_0:
|
||||||
break;
|
break;
|
||||||
case WAIT_OBJECT_0 + 1:
|
case WAIT_OBJECT_0 + 1:
|
||||||
if (_my_tls.call_signal_handler ())
|
|
||||||
goto restart;
|
|
||||||
PurgeComm (get_handle (), PURGE_TXABORT);
|
PurgeComm (get_handle (), PURGE_TXABORT);
|
||||||
set_sig_errno (EINTR);
|
set_sig_errno (EINTR);
|
||||||
ForceCloseHandle (write_status.hEvent);
|
ForceCloseHandle (write_status.hEvent);
|
||||||
|
@ -717,8 +717,6 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
|
|||||||
case WAIT_OBJECT_0 + 1:
|
case WAIT_OBJECT_0 + 1:
|
||||||
if (totalread > 0)
|
if (totalread > 0)
|
||||||
goto out;
|
goto out;
|
||||||
if (_my_tls.call_signal_handler ())
|
|
||||||
continue;
|
|
||||||
termios_printf ("wait catched signal");
|
termios_printf ("wait catched signal");
|
||||||
set_sig_errno (EINTR);
|
set_sig_errno (EINTR);
|
||||||
totalread = -1;
|
totalread = -1;
|
||||||
@ -754,8 +752,6 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
|
|||||||
case WAIT_OBJECT_0 + 1:
|
case WAIT_OBJECT_0 + 1:
|
||||||
if (totalread > 0)
|
if (totalread > 0)
|
||||||
goto out;
|
goto out;
|
||||||
if (_my_tls.call_signal_handler ())
|
|
||||||
continue;
|
|
||||||
termios_printf ("wait for mutex catched signal");
|
termios_printf ("wait for mutex catched signal");
|
||||||
set_sig_errno (EINTR);
|
set_sig_errno (EINTR);
|
||||||
totalread = -1;
|
totalread = -1;
|
||||||
|
@ -33,7 +33,7 @@ ioctl (int fd, int cmd, ...)
|
|||||||
char *argp = va_arg (ap, char *);
|
char *argp = va_arg (ap, char *);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
debug_printf ("fd %d, cmd %x", fd, cmd);
|
debug_printf ("ioctl(fd %d, cmd %p)", fd, cmd);
|
||||||
int res;
|
int res;
|
||||||
/* FIXME: This stinks. There are collisions between cmd types
|
/* FIXME: This stinks. There are collisions between cmd types
|
||||||
depending on whether fd is associated with a pty master or not.
|
depending on whether fd is associated with a pty master or not.
|
||||||
@ -58,6 +58,6 @@ ioctl (int fd, int cmd, ...)
|
|||||||
res = cfd->ioctl (cmd, argp);
|
res = cfd->ioctl (cmd, argp);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
debug_printf ("returning %d", res);
|
syscall_printf ("%R = ioctl(%d, %p, ...)", res, fd, cmd);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -85,13 +85,24 @@ static inline DWORD __attribute__ ((always_inline))
|
|||||||
cygwait (HANDLE h, DWORD howlong = INFINITE)
|
cygwait (HANDLE h, DWORD howlong = INFINITE)
|
||||||
{
|
{
|
||||||
HANDLE w4[3];
|
HANDLE w4[3];
|
||||||
int n = 0;
|
DWORD n = 0;
|
||||||
if ((w4[n] = h) != NULL)
|
DWORD wait_signal;
|
||||||
n++;
|
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;
|
w4[n++] = signal_arrived;
|
||||||
if ((w4[n] = pthread::get_cancel_event ()) != NULL)
|
if ((w4[n] = pthread::get_cancel_event ()) != NULL)
|
||||||
n++;
|
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))
|
static inline DWORD __attribute__ ((always_inline))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user