From 9d752c75a8cc86f782744075be4cbffc33152ae6 Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Sun, 10 Apr 2022 20:24:44 -0700
Subject: [PATCH] Install OperationCallback for all executed JS scripts

JS doors with the "Use Shell or New Context" option enabled in SCFG and JS
modules installed a global hot key handlers would not automatically terminate
when the user disconnected (and js.auto_terminate was true, the default).
I'm not sure why the operation callback was only installed when scope==NULL
but always installing it fixes the issue with some global hot key modules
and JS doors becoming "zombies" when a user disconnects while running them.
---
 src/sbbs3/exec.cpp | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/sbbs3/exec.cpp b/src/sbbs3/exec.cpp
index 6d5167c79a..4d5e8a42db 100644
--- a/src/sbbs3/exec.cpp
+++ b/src/sbbs3/exec.cpp
@@ -679,13 +679,8 @@ long sbbs_t::js_execfile(const char *cmd, const char* startup_dir, JSObject* sco
 
 	if(scope==NULL) {
 		js_callback.counter=0;	// Reset loop counter
-
-#if JS_VERSION>180
-		JS_SetOperationCallback(js_cx, js_OperationCallback);
-#else
-		JS_SetBranchCallback(js_cx, js_BranchCallback);
-#endif
 	}
+	JS_SetOperationCallback(js_cx, js_OperationCallback);
 	js_PrepareToExecute(js_cx, js_glob, path, startup_dir, js_scope);
 	events = js_callback.events;
 	js_callback.events = NULL;
-- 
GitLab