OSDN Git Service

* cygthread.h (cygthread::name): Very minor formatting tweak.
authorcgf <cgf>
Tue, 13 Dec 2011 04:11:43 +0000 (04:11 +0000)
committercgf <cgf>
Tue, 13 Dec 2011 04:11:43 +0000 (04:11 +0000)
* 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.

winsup/cygwin/ChangeLog
winsup/cygwin/cygthread.h
winsup/cygwin/exceptions.cc
winsup/cygwin/fhandler.cc
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_console.cc
winsup/cygwin/fhandler_serial.cc
winsup/cygwin/fhandler_tty.cc
winsup/cygwin/ioctl.cc
winsup/cygwin/sigproc.h

index 25ee248..9b3cb02 100644 (file)
@@ -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>
 
        * fhandler_process.cc (dos_drive_mappings): Partially rewrite to
index a15889a..642604d 100644 (file)
@@ -38,7 +38,7 @@ class cygthread
   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);
index 351532a..97f04b2 100644 (file)
@@ -1330,6 +1330,7 @@ _cygtls::call_signal_handler ()
          _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;
index 48e114f..c6388cc 100644 (file)
@@ -1942,14 +1942,9 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
        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 */
@@ -1964,8 +1959,6 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
 
   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;
@@ -2003,9 +1996,6 @@ fhandler_base_overlapped::raw_read (void *ptr, size_t& len)
                           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:
@@ -2059,8 +2049,6 @@ fhandler_base_overlapped::raw_write (const void *ptr, size_t len)
              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:
index a6e1834..b1324c5 100644 (file)
@@ -620,7 +620,6 @@ protected:
   {
     overlapped_unknown = 0,
     overlapped_success,
-    overlapped_signal,
     overlapped_nonblocking_no_data,
     overlapped_error
   };
index e04e0aa..6347bd5 100644 (file)
@@ -347,14 +347,11 @@ fhandler_console::read (void *pv, size_t& buflen)
        }
 
       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 ();
index 4c33d5e..5a53a11 100644 (file)
@@ -95,7 +95,6 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
          else
            {
              overlapped_armed = 1;
-restart:
              switch (cygwait (io_status.hEvent))
                {
                case WAIT_OBJECT_0:
@@ -105,8 +104,6 @@ restart:
                  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;
@@ -202,14 +199,11 @@ fhandler_serial::raw_write (const void *ptr, size_t len)
 
       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);
index d8927cf..61fb861 100644 (file)
@@ -717,8 +717,6 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
        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;
@@ -754,8 +752,6 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
        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;
index 25f18af..fa02db4 100644 (file)
@@ -33,7 +33,7 @@ ioctl (int fd, int cmd, ...)
   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.
@@ -58,6 +58,6 @@ ioctl (int fd, int cmd, ...)
   res = cfd->ioctl (cmd, argp);
 
 out:
-  debug_printf ("returning %d", res);
+  syscall_printf ("%R = ioctl(%d, %p, ...)", res, fd, cmd);
   return res;
 }
index 72427a4..0cfac86 100644 (file)
@@ -85,13 +85,24 @@ static inline DWORD __attribute__ ((always_inline))
 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))