From 194f6aef1d376712348f40423f48d0ce97465efa Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 7 Apr 2025 20:22:20 +0200 Subject: [PATCH] Clean BackboneInterface file descriptor refs immediately --- RNS/Interfaces/BackboneInterface.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RNS/Interfaces/BackboneInterface.py b/RNS/Interfaces/BackboneInterface.py index 9acae87..3181b56 100644 --- a/RNS/Interfaces/BackboneInterface.py +++ b/RNS/Interfaces/BackboneInterface.py @@ -231,6 +231,7 @@ class BackboneInterface(Interface): if len(received_bytes): spawned_interface.receive(received_bytes) else: BackboneInterface.deregister_fileno(fileno); client_socket.close() + if fileno in BackboneInterface.spawned_interface_filenos: BackboneInterface.spawned_interface_filenos.pop(fileno) spawned_interface.receive(received_bytes) elif client_socket and fileno == client_socket.fileno() and (event & select.EPOLLOUT): @@ -240,6 +241,7 @@ class BackboneInterface(Interface): written = 0 if not spawned_interface.detached: RNS.log(f"Error while writing to {spawned_interface}: {e}", RNS.LOG_DEBUG) BackboneInterface.deregister_fileno(fileno) + if fileno in BackboneInterface.spawned_interface_filenos: BackboneInterface.spawned_interface_filenos.pop(fileno) try: client_socket.close() except Exception as e: RNS.log(f"Error while closing socket for {spawned_interface}: {e}", RNS.LOG_ERROR) spawned_interface.receive(b"") @@ -251,6 +253,7 @@ class BackboneInterface(Interface): elif client_socket and fileno == client_socket.fileno() and event & (select.EPOLLHUP): BackboneInterface.deregister_fileno(fileno) + if fileno in BackboneInterface.spawned_interface_filenos: BackboneInterface.spawned_interface_filenos.pop(fileno) try: client_socket.close() except Exception as e: RNS.log(f"Error while closing socket for {spawned_interface}: {e}", RNS.LOG_ERROR) spawned_interface.receive(b"")