[threads] Fix Posix async resume (#3861)
authorLudovic Henry <ludovic@xamarin.com>
Tue, 1 Nov 2016 18:45:47 +0000 (14:45 -0400)
committerGitHub <noreply@github.com>
Tue, 1 Nov 2016 18:45:47 +0000 (14:45 -0400)
If we fail to send the signal, we should not add a pending operation, as the signal handler is never going to answer this operation (via mono_threads_notify_initiator_of_resume).

mono/utils/mono-threads-posix.c

index 0592cd68d27f321bea9e119e1f2290961548a5e4..5447a8fe93f412b9eef902ff644c9246197a7830 100644 (file)
@@ -286,8 +286,13 @@ This begins async resume. This function must do the following:
 gboolean
 mono_threads_suspend_begin_async_resume (MonoThreadInfo *info)
 {
-       mono_threads_add_to_pending_operation_set (info);
-       return mono_threads_pthread_kill (info, mono_threads_suspend_get_restart_signal ()) == 0;
+       int sig = mono_threads_suspend_get_restart_signal ();
+
+       if (!mono_threads_pthread_kill (info, sig)) {
+               mono_threads_add_to_pending_operation_set (info);
+               return TRUE;
+       }
+       return FALSE;
 }
 
 void