[runtime] Change mono_thread_current_check_pending_interrupt to use mono_set_pending_...
[mono.git] / mono / metadata / monitor.c
index 6cf9691777ea783631f39c7cac24c239cd180a7f..b9a305121641975286467b84392ceba8856a4111 100644 (file)
@@ -1250,7 +1250,8 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms)
        mon = lock_word_get_inflated_lock (lw);
 
        /* Do this WaitSleepJoin check before creating the event handle */
-       mono_thread_current_check_pending_interrupt ();
+       if (mono_thread_current_check_pending_interrupt ())
+               return FALSE;
        
        event = CreateEvent (NULL, FALSE, FALSE, NULL);
        if (event == NULL) {
@@ -1260,7 +1261,11 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms)
        
        LOCK_DEBUG (g_message ("%s: (%d) queuing handle %p", __func__, mono_thread_info_get_small_id (), event));
 
-       mono_thread_current_check_pending_interrupt ();
+       /* This looks superfluous */
+       if (mono_thread_current_check_pending_interrupt ()) {
+               CloseHandle (event);
+               return FALSE;
+       }
        
        mono_thread_set_state (thread, ThreadState_WaitSleepJoin);