From 58bf48c5e8a7a75458c4c231cdcb67e3d46e006e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Tue, 24 Sep 2019 12:06:43 +0200 Subject: [PATCH] Backend: Fixed issue in error handling. Backend callbacks throwing errors caused backends to enter a state where they get stuck throwing "Backend already running - cannot reenter.". One way of entering this state was to have a sendfile callback throwing an error. --- src/backend.cmod | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/backend.cmod b/src/backend.cmod index 73e14c0710..a9561ff604 100644 --- a/src/backend.cmod +++ b/src/backend.cmod @@ -2056,7 +2056,8 @@ PIKECLASS Backend * but it has not completed in time). */ static int low_backend_once_setup(struct Backend_struct *me, - struct timeval *start_time) + struct timeval *start_time, + ONERROR *uwp) { #ifdef PIKE_DEBUG struct timeval max_timeout; @@ -2129,6 +2130,8 @@ PIKECLASS Backend me->exec_thread = 1; #endif + LOW_SET_ONERROR(uwp, low_backend_cleanup, me); + /* Call outs */ if(me->num_pending_calls) if(next_timeout->tv_sec < 0 || @@ -3739,10 +3742,10 @@ static void noteEvents(CFFileDescriptorRef fdref, CFOptionFlags UNUSED(callBackT DECLARE_POLL_EXTRAS; #endif /* DECLARE_POLL_EXTRAS */ - if ((done_something = low_backend_once_setup(pdb->backend, &start_time))) { + if ((done_something = + low_backend_once_setup(pdb->backend, &start_time, &uwp))) { goto low_backend_round_done; } - SET_ONERROR(uwp, low_backend_cleanup, me); if (TYPEOF(me->before_callback) != T_INT) call_backend_monitor_cb (me, &me->before_callback); @@ -4612,10 +4615,10 @@ PIKECLASS PollBackend DECLARE_POLL_EXTRAS; #endif /* DECLARE_POLL_EXTRAS */ - if ((done_something = low_backend_once_setup(pb->backend, &start_time))) { + if ((done_something = + low_backend_once_setup(pb->backend, &start_time, &uwp))) { goto low_backend_round_done; } - SET_ONERROR(uwp, low_backend_cleanup, THIS->backend); if (TYPEOF(me->before_callback) != T_INT) call_backend_monitor_cb (me, &me->before_callback); @@ -5190,10 +5193,10 @@ PIKECLASS SelectBackend DECLARE_POLL_EXTRAS; #endif /* DECLARE_POLL_EXTRAS */ - if ((done_something = low_backend_once_setup(sb->backend, &start_time))) { + if ((done_something = + low_backend_once_setup(sb->backend, &start_time, &uwp))) { goto low_backend_round_done; } - SET_ONERROR(uwp, low_backend_cleanup, THIS->backend); if (TYPEOF(me->before_callback) != T_INT) call_backend_monitor_cb (me, &me->before_callback); -- GitLab