From d541a808179f7e209c7b8b7e88fde2429b39c3a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Sun, 4 Apr 2021 23:22:57 -0400
Subject: [PATCH] Keep running the event loop while the run queue is not empty

Previously, timed or polled callbacks were required to keep the
event loop running.
---
 src/sbbs3/js_internal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/sbbs3/js_internal.c b/src/sbbs3/js_internal.c
index eee4121fc1..9dc3436c7a 100644
--- a/src/sbbs3/js_internal.c
+++ b/src/sbbs3/js_internal.c
@@ -1134,7 +1134,7 @@ js_handle_events(JSContext *cx, js_callback_t *cb, volatile int *terminated)
 	if (!cb->events_supported)
 		return JS_FALSE;
 
-	while (cb->keepGoing && !JS_IsExceptionPending(cx) && cb->events && !*terminated) {
+	while (cb->keepGoing && !JS_IsExceptionPending(cx) && (cb->events || cb->rq_head) && !*terminated) {
 		timeout = -1;	// Infinity by default...
 		now = (uint64_t)(xp_timer() * 1000);
 		ev = NULL;
@@ -1147,7 +1147,7 @@ js_handle_events(JSContext *cx, js_callback_t *cb, volatile int *terminated)
 #else
 		hsock = 0;
 #endif
-		
+
 #ifdef PREFER_POLL
 		for (ev = *head; ev; ev = ev->next) {
 			if (ev->type == JS_EVENT_SOCKET_READABLE || ev->type == JS_EVENT_SOCKET_READABLE_ONCE
-- 
GitLab