[threads] Remove unecessary block/unblock suspend ACK signal
authorLudovic Henry <ludovic@xamarin.com>
Tue, 2 Feb 2016 10:23:25 +0000 (10:23 +0000)
committerLudovic Henry <ludovic@xamarin.com>
Thu, 4 Feb 2016 13:38:25 +0000 (13:38 +0000)
Blocking suspend_ack_signal_mask is only useful if we are notifying the initiator of suspend followed by waiting on the suspend_signal_mask.

mono/utils/mono-threads-posix-signals.c

index 155f830a0fa15bcda4b9e803617f938c6c513889..39caeb54d65b68c918bdc04f991d2a53c4163e13 100644 (file)
@@ -180,13 +180,6 @@ suspend_signal_handler (int _dummy, siginfo_t *info, void *context)
        /* thread_state_init_from_sigctx return FALSE if the current thread is detaching and suspend can't continue. */
        current->suspend_can_continue = ret;
 
-       /*
-       Block the restart signal.
-       We need to block the restart signal while posting to the suspend_ack semaphore or we race to sigsuspend,
-       which might miss the signal and get stuck.
-       */
-       pthread_sigmask (SIG_BLOCK, &suspend_ack_signal_mask, NULL);
-
        /* This thread is doomed, all we can do is give up and let the suspender recover. */
        if (!ret) {
                THREADS_SUSPEND_DEBUG ("\tThread is dying, failed to capture state %p\n", current);
@@ -195,12 +188,16 @@ suspend_signal_handler (int _dummy, siginfo_t *info, void *context)
                /* We're done suspending */
                mono_threads_notify_initiator_of_suspend (current);
 
-               /* Unblock the restart signal. */
-               pthread_sigmask (SIG_UNBLOCK, &suspend_ack_signal_mask, NULL);
-
                goto done;
        }
 
+       /*
+       Block the restart signal.
+       We need to block the restart signal while posting to the suspend_ack semaphore or we race to sigsuspend,
+       which might miss the signal and get stuck.
+       */
+       pthread_sigmask (SIG_BLOCK, &suspend_ack_signal_mask, NULL);
+
        /* We're done suspending */
        mono_threads_notify_initiator_of_suspend (current);