From cd9b8e51731e6170fde6b957fca67c256b597aac Mon Sep 17 00:00:00 2001 From: DJ2LS <75909252+DJ2LS@users.noreply.github.com> Date: Thu, 17 Nov 2022 14:55:20 +0100 Subject: [PATCH] interrupt arq session while opening --- tnc/data_handler.py | 7 +++++++ tnc/sock.py | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tnc/data_handler.py b/tnc/data_handler.py index 63768811..d4a62709 100644 --- a/tnc/data_handler.py +++ b/tnc/data_handler.py @@ -1369,6 +1369,11 @@ class DATA: if static.ARQ_SESSION: return True + # Stop waiting and interrupt if data channel is getting closed while opening + if static.ARQ_SESSION_STATE == "disconnecting": + self.close_session() + return False + # Session connect timeout, send close_session frame to # attempt to clean up the far-side, if it received the # open_session frame and can still hear us. @@ -1444,6 +1449,8 @@ class DATA: self.send_disconnect_frame() self.arq_cleanup() + static.ARQ_SESSION_STATE = "disconnected" + def received_session_close(self, data_in: bytes): """ Closes the session when a close session frame is received and diff --git a/tnc/sock.py b/tnc/sock.py index aa5adb4c..6699ce94 100644 --- a/tnc/sock.py +++ b/tnc/sock.py @@ -332,9 +332,11 @@ def process_tnc_commands(data): # DISCONNECT ---------------------------------------------------------- if received_json["type"] == "arq" and received_json["command"] == "disconnect": - # send ping frame and wait for ACK try: DATA_QUEUE_TRANSMIT.put(["DISCONNECT"]) + + # set early disconnecting state so we can interrupt connection attemtps + static.ARQ_SESSION_STATE = "disconnecting" command_response("disconnect", True) except Exception as err: command_response("disconnect", False)