From e68dcdc9fe681273454af1394b5bbf8c733a8632 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Thu, 29 Dec 2022 20:12:02 -0500
Subject: [PATCH] Call RingBufRead() when avail == 0 to reset events

If something else sets these events, and they never get cleared,
this will fall into a tight loop.
---
 src/sbbs3/main.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp
index 5013c752fc..3c15875326 100644
--- a/src/sbbs3/main.cpp
+++ b/src/sbbs3/main.cpp
@@ -2364,8 +2364,11 @@ void output_thread(void* arg)
 			avail = RingBufFull(&sbbs->outbuf);
 
 			// If flushing or terminating, there will be nothing available
-			if (avail == 0)
+			if (avail == 0) {
+				// Reset data/highwater events
+				RingBufRead(&sbbs->outbuf, NULL, 0);
 				continue;
+			}
 
 			/*
 			 * At this point, there's something to send and,
-- 
GitLab