From 4e9883893ba55a40fb4a8b3c1ef7a934c6d96b29 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Tue, 6 Dec 2011 20:37:46 +0000
Subject: [PATCH] Don't drop characters when the input buffer (from remote) is
 full for over 5 seconds, just continue waiting (and logging warnings).

---
 src/sbbs3/main.cpp | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp
index 551ebfe4bf..832404c2b6 100644
--- a/src/sbbs3/main.cpp
+++ b/src/sbbs3/main.cpp
@@ -1614,19 +1614,18 @@ void input_thread(void *arg)
 
     	rd=RingBufFree(&sbbs->inbuf);
 
-		if(!rd) { // input buffer full
+		if(rd==0) { // input buffer full
 			lprintf(LOG_WARNING,"Node %d !WARNING input buffer full", sbbs->cfg.node_num);
         	// wait up to 5 seconds to empty (1 byte min)
 			time_t start=time(NULL);
-            while((rd=RingBufFree(&sbbs->inbuf))==0) {
-            	if(time(NULL)-start>=5) {
-                	rd=1;
-					if(pthread_mutex_unlock(&sbbs->input_thread_mutex)!=0)
-						sbbs->errormsg(WHERE,ERR_UNLOCK,"input_thread_mutex",0);
-                	break;
-                }
+            while((rd=RingBufFree(&sbbs->inbuf))==0 && time(NULL)-start<5) {
                 YIELD();
             }
+			if(rd==0) {	/* input buffer still full */
+				if(pthread_mutex_unlock(&sbbs->input_thread_mutex)!=0)
+					sbbs->errormsg(WHERE,ERR_UNLOCK,"input_thread_mutex",0);
+				continue;
+			}
 		}
 		
 	    if(rd > (int)sizeof(inbuf))
-- 
GitLab