From 7a96e2b3c59cb0f5b96c22ae8d14f37832cee86b Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Fri, 4 Dec 2015 21:38:01 +0000 Subject: [PATCH] Resolve FAQ: Don't report a JavaScript warning ("Disconnected") until the OperationCallback has been executed 10 times with the user offline. This gives the executing script ample time to recognize the disconnected state and exit gracefully. Script that do not check/notice that the user has disconnected will still be auto-terminated (by default) and this warning will still be logged in those cases. The value 10 was picked at random and appears to work fine. --- src/sbbs3/exec.cpp | 5 +++-- src/sbbs3/sbbsdefs.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sbbs3/exec.cpp b/src/sbbs3/exec.cpp index c425f2d4a9..999f8d4dca 100644 --- a/src/sbbs3/exec.cpp +++ b/src/sbbs3/exec.cpp @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -548,7 +548,8 @@ js_OperationCallback(JSContext *cx) return(JS_FALSE); } - if(sbbs->js_callback.auto_terminate && !sbbs->online) { + if(sbbs->js_callback.auto_terminate && !sbbs->online + && ++sbbs->js_callback.offline_counter >= 10) { JS_ReportWarning(cx,"Disconnected"); sbbs->js_callback.counter=0; JS_SetOperationCallback(cx, js_OperationCallback); diff --git a/src/sbbs3/sbbsdefs.h b/src/sbbs3/sbbsdefs.h index f19bba70b8..b75ea0ba4a 100644 --- a/src/sbbs3/sbbsdefs.h +++ b/src/sbbs3/sbbsdefs.h @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2015 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -85,6 +85,7 @@ typedef struct js_callback { uint32_t yield_interval; uint32_t gc_interval; uint32_t gc_attempts; + uint32_t offline_counter; BOOL auto_terminate; volatile BOOL* terminated; BOOL bg; -- GitLab