From 34e0ac71eb3bb4401b0742b4f8e5d78ee9bc5124 Mon Sep 17 00:00:00 2001 From: Aviv Bergman Date: Tue, 5 Aug 2025 18:30:52 +1000 Subject: [PATCH] Handle abort, avoid joining self --- src/smbprotocol/connection.py | 2 +- src/smbprotocol/transport.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/smbprotocol/connection.py b/src/smbprotocol/connection.py index b1c06e0..93320ab 100644 --- a/src/smbprotocol/connection.py +++ b/src/smbprotocol/connection.py @@ -953,7 +953,7 @@ def disconnect(self, close=True, timeout=None): log.info("Disconnecting transport connection") self.transport.close() - if self._t_worker: + if self._t_worker and self._t_worker.ident != threading.get_ident(): self._t_worker.join(timeout=2) def send( diff --git a/src/smbprotocol/transport.py b/src/smbprotocol/transport.py index 2288239..9f5cd9a 100644 --- a/src/smbprotocol/transport.py +++ b/src/smbprotocol/transport.py @@ -145,7 +145,7 @@ def _recv(self, length, timeout): except OSError as e: # Windows will raise this error if the socket has been shutdown, Linux return returns an empty byte # string so we just replicate that. - if e.errno not in [errno.ESHUTDOWN, errno.ECONNRESET]: + if e.errno not in [errno.ESHUTDOWN, errno.ECONNRESET, errno.ECONNABORTED]: # Avoid collecting coverage here to avoid CI failing due to race condition differences raise # pragma: no cover b_data = b""