From e5f64faf337040f12844c4cc874fbb9a489d1d16 Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on Windows)" <rob@synchro.net> Date: Tue, 19 Sep 2023 18:32:12 -0700 Subject: [PATCH] Log a critical error message if a node is WFC, but its socket is still in use This should avoid/work-around issue #630 Nelgin's terminal server log indicated that the node's configuration was being reloaded for a new client connection (which doesn't normally/always happen, only when there's been a config file change or a node "rerun" requested), while there was still a user online using that node. This would explain the segfault (configuration fields being freed and reallocated). The node_socket[] array indicates when a node thread is actively servicing a client, so it should contain INVALID_SOCKET for the any node's that WFC. If it doesn't, that means something/someone changed the node's status value to 0 (WFC) in the node.dab file while the node was still in-use. Let's not crash in this case and rather just log the message and give the client the next available node (if any). --- src/sbbs3/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp index cc1072abb2..283d806aad 100644 --- a/src/sbbs3/main.cpp +++ b/src/sbbs3/main.cpp @@ -5490,6 +5490,12 @@ NO_SSH: if(sbbs->getnodedat(i,&node,1)!=0) continue; if(node.status==NODE_WFC) { + if(node_socket[i - 1] != INVALID_SOCKET) { + lprintf(LOG_CRIT, "%04d !Node %d status is WFC, but the node socket (%d) and thread are still in use!" + ,client_socket, i, node_socket[i - 1]); + sbbs->putnodedat(i, &node); + continue; + } node.status=NODE_LOGON; #ifdef USE_CRYPTLIB if(ssh) -- GitLab