commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r813322 - in /commons/sandbox/runtime/trunk/src/main/native: include/arch/windows/acr_arch.h os/win32/signals.c
Date Thu, 10 Sep 2009 09:06:03 GMT
Author: mturk
Date: Thu Sep 10 09:06:03 2009
New Revision: 813322

URL: http://svn.apache.org/viewvc?rev=813322&view=rev
Log:
Use signal queue that allows multiple signals to be handled

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
    commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c

Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h?rev=813322&r1=813321&r2=813322&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h Thu Sep
10 09:06:03 2009
@@ -433,7 +433,7 @@
 #define SIG_SGE     (void (*)(int))4    /* signal gets error     */
 #define SIG_ACK     (void (*)(int))5    /* acknowledge           */
 
-
+#define sigmask(S)  (1 << ((S) - 1))
 /*
  * ---------------------------------------------------------------------
  * end   of POSIX utilities

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c?rev=813322&r1=813321&r2=813322&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c Thu Sep 10 09:06:03 2009
@@ -47,7 +47,8 @@
 
 static CRITICAL_SECTION signal_lock;
 int           dll_daemon_mode = 0;
-volatile LONG current_signal_value;
+volatile LONG current_signal_mask;
+volatile LONG current_signal_queue;
 volatile LONG current_signal_listeners;
 
 static void make_security_cookie(acr_sig_msg_t *msg, const wchar_t *salt,
@@ -134,7 +135,17 @@
     if (posix_signal) {
         /* Sync with callback handler */
         EnterCriticalSection(&signal_lock);
-        InterlockedExchange(&current_signal_value, posix_signal);
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+        /* XXX: Do we really need an atomic op here?
+         */
+        _InterlockedOr(&current_signal_queue, sigmask(posix_signal));
+#else
+        /* We don't have compiler intrinsic.
+         * CriticalSection should guard the value for the majority
+         * of cases.
+         */
+        current_signal_queue |= sigmask(posix_signal);
+#endif
         /* Fire the signal events.
          * The first locked listener will handle
          * the signal.
@@ -187,6 +198,7 @@
  */
 DWORD ACR_DeliverSignals()
 {
+    LONG  mask;
     DWORD rc = ACR_EINTR;
     /* We are invoked from one of the waiters.
      *
@@ -207,14 +219,22 @@
         /* Someone just entered while we obtained the lock
          */
     }
-    switch (current_signal_value) {
-        case SIGKILL:
-        case SIGQUIT:
-        case SIGTERM:
-            rc = ACR_INCOMPLETE;
-        default:
-            rc = ACR_EINTR;
-        break;
+    if ((mask = (current_signal_queue & ~current_signal_mask))) {
+        int i;
+        for (i = 1; i < _NSIG, rc == ACR_EINTR; i++) {
+            if (mask & sigmask(i)) {
+                switch (i) {
+                    case SIGKILL:
+                    case SIGQUIT:
+                    case SIGTERM:
+                        rc = ACR_INCOMPLETE;
+                    break;
+                    default:
+                        rc = ACR_EINTR;
+                    break;
+                }
+            }
+        }
     }
     LeaveCriticalSection(&signal_lock);
     return rc;



Mime
View raw message