From 49e1ae1121cc8e1eec615766d09a24fb482a087a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Wed, 7 May 2014 20:03:39 +0200
Subject: [PATCH] Backend: Improve robustness of reentrancy check.

The reentrancy protection was broken after the first detection.
---
 src/backend.cmod | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/backend.cmod b/src/backend.cmod
index 826a0eaa88..db05aa48fd 100644
--- a/src/backend.cmod
+++ b/src/backend.cmod
@@ -3650,8 +3650,8 @@ static void noteEvents(CFFileDescriptorRef fdref, CFOptionFlags UNUSED(callBackT
     DECLARE_POLL_EXTRAS;
 #endif /* DECLARE_POLL_EXTRAS */
 
-    SET_ONERROR(uwp, low_backend_cleanup, me);
     low_backend_once_setup(pdb->backend, &start_time);
+    SET_ONERROR(uwp, low_backend_cleanup, me);
 
     if (TYPEOF(me->before_callback) != T_INT)
       call_backend_monitor_cb (me, &me->before_callback);
@@ -4514,8 +4514,8 @@ PIKECLASS PollBackend
     DECLARE_POLL_EXTRAS;
 #endif /* DECLARE_POLL_EXTRAS */
 
-    SET_ONERROR(uwp, low_backend_cleanup, THIS->backend);
     low_backend_once_setup(pb->backend, &start_time);
+    SET_ONERROR(uwp, low_backend_cleanup, THIS->backend);
 
     if (TYPEOF(me->before_callback) != T_INT)
       call_backend_monitor_cb (me, &me->before_callback);
@@ -5083,8 +5083,8 @@ PIKECLASS SelectBackend
     DECLARE_POLL_EXTRAS;
 #endif /* DECLARE_POLL_EXTRAS */
 
-    SET_ONERROR(uwp, low_backend_cleanup, THIS->backend);
     low_backend_once_setup(sb->backend, &start_time);
+    SET_ONERROR(uwp, low_backend_cleanup, THIS->backend);
 
     if (TYPEOF(me->before_callback) != T_INT)
       call_backend_monitor_cb (me, &me->before_callback);
-- 
GitLab