From 2f8c56f7e30daae16258f7afb04b3ff7ade7c923 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Sun, 25 Mar 2018 21:07:52 +0000 Subject: [PATCH] Attempt to address multiple redundant SSH related error/log messages from the output_thread which may occur after an SSH-related error in the input thread, e.g.: Sun Mar 25 2018 01:45 pm bbs.synchro.net Node 6 SSH ERROR 'Bad argument, parameter 2' (-2) setting channel Sun Mar 25 2018 01:45 pm bbs.synchro.net Node 6 SSH ERROR 'Bad argument, parameter 2' (-2) setting channel Sun Mar 25 2018 01:45 pm bbs.synchro.net Node 6 SSH ERROR 'Bad argument, parameter 2' (-2) setting channel Sun Mar 25 2018 01:45 pm bbs.synchro.net Node 6 SSH ERROR 'Bad argument, parameter 2' (-2) setting channel Sun Mar 25 2018 01:45 pm bbs.synchro.net Node 6 SSH ERROR 'Bad argument, parameter 2' (-2) setting channel Sun Mar 25 2018 01:45 pm bbs.synchro.net Node 6 SSH ERROR 'Bad argument, parameter 2' (-2) setting channel ... by introducing a new sbbs_t member variable: terminate_output_thread which is only set to true when the input_thread is terminating. If there is any possibility that the input_thread could startup and get an SSH error before the output_thread even starts, then we will want to move the terminate_output_thread=false initialization to the sbbs_t constructor. --- src/sbbs3/main.cpp | 6 ++++-- src/sbbs3/sbbs.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp index 7a6867affd..20550615d6 100644 --- a/src/sbbs3/main.cpp +++ b/src/sbbs3/main.cpp @@ -2044,6 +2044,7 @@ void input_thread(void *arg) sbbs->sys_status|=SS_ABORT; /* as though Ctrl-C were hit */ sbbs->input_thread_running = false; + sbbs->terminate_output_thread = true; if(node_socket[sbbs->cfg.node_num-1]==INVALID_SOCKET) // Shutdown locally sbbs->terminated = true; // Signal JS to stop execution @@ -2318,9 +2319,10 @@ void output_thread(void* arg) } } #endif + sbbs->terminate_output_thread = false; /* Note: do not terminate when online==FALSE, that is expected for the terminal server output_thread */ - while(sbbs->client_socket!=INVALID_SOCKET && !terminate_server) { + while(sbbs->client_socket!=INVALID_SOCKET && !terminate_server && !sbbs->terminate_output_thread) { /* * I'd like to check the linear buffer against the highwater * at this point, but it would get too clumsy imho - Deuce @@ -2328,7 +2330,7 @@ void output_thread(void* arg) * Actually, another option would just be to have the size * of the linear buffer equal to the MSS... any larger and * you could have small sends off the end. this would - * probobly be even clumbsier + * probably be even clumsier */ if(bufbot == buftop) { /* Wait for something to output in the RingBuffer */ diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index 5ec2f1ca62..994b8fb19d 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -380,6 +380,7 @@ public: bool event_thread_running; bool output_thread_running; bool input_thread_running; + bool terminate_output_thread; #ifdef JAVASCRIPT -- GitLab