From 41af8b34ae2ff4c21431cff14fd32ac42bad7012 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Thu, 11 Oct 2018 06:13:31 +0000
Subject: [PATCH] Fix a long standing-bug where if the "inactivity hangup"
 timeout value is set *lower* than the "inactivity warning" timeout value, the
 hangup timer wouldn't actually take effect until after the warning timeout
 elapsed. This made the login.js modification (rev 1.14) where we reduce the
 hangup timeout (by 75%) when an ANSI terminal is not detected, not effective.

---
 src/sbbs3/getkey.cpp | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/sbbs3/getkey.cpp b/src/sbbs3/getkey.cpp
index 203741cd8d..e144aa07a6 100644
--- a/src/sbbs3/getkey.cpp
+++ b/src/sbbs3/getkey.cpp
@@ -263,27 +263,27 @@ char sbbs_t::getkey(long mode)
 		}
 			
 		if(online==ON_REMOTE && !(console&CON_NO_INACT)
-			&& now-timeout>=cfg.sec_warn) { 					/* warning */
-			if(sys_status&SS_USERON && cfg.sec_warn!=cfg.sec_hangup) {
+			&& (now-timeout >= cfg.sec_warn || now-timeout >= cfg.sec_hangup)) {
+			if(sys_status&SS_USERON && cfg.sec_warn < cfg.sec_hangup) {
 				SAVELINE;
 				bputs(text[AreYouThere]); 
 			}
 			else
 				bputs("\7\7");
-			while(!inkey(K_NONE,100) && online && now-timeout>=cfg.sec_warn) {
+			while(!inkey(K_NONE,100) && online && now-timeout < cfg.sec_hangup) {
 				now=time(NULL);
-				if(now-timeout>=cfg.sec_hangup) {
-					if(online==ON_REMOTE) {
-						console|=CON_R_ECHO;
-						console&=~CON_R_ECHOX; 
-					}
-					bputs(text[CallBackWhenYoureThere]);
-					logline(LOG_NOTICE,nulstr,"Inactive");
-					hangup();
-					return(0); 
+			}
+			if(now-timeout >= cfg.sec_hangup) {
+				if(online==ON_REMOTE) {
+					console|=CON_R_ECHO;
+					console&=~CON_R_ECHOX; 
 				}
+				bputs(text[CallBackWhenYoureThere]);
+				logline(LOG_NOTICE,nulstr,"Inactive");
+				hangup();
+				return(0); 
 			}
-			if(sys_status&SS_USERON && cfg.sec_warn!=cfg.sec_hangup) {
+			if(sys_status&SS_USERON) {
 				bputs("\r\1n\1>");
 				RESTORELINE; 
 			}
-- 
GitLab