Skip to content

Commit

Permalink
Fix race condition when closing a channel
Browse files Browse the repository at this point in the history
This commit fixes a race between a client sending a channel close
message and receiving an exit status or other channel requests
from the server. Thanks go to Wilson Conley for providing sample
code to reproduce the problem!
  • Loading branch information
ronf committed Aug 23, 2024
1 parent f2912e8 commit 3698c93
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion asyncssh/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,11 @@ def _service_next_request(self) -> None:
handler = cast(_RequestHandler, getattr(self, name, None))

if handler:
result = cast(Optional[bool], handler(packet))
if self._session:
result = cast(Optional[bool], handler(packet))
else:
# Ignore requests received after application closes the channel
result = True
else:
self.logger.debug1('Received unknown channel request: %s', request)
result = False
Expand Down

0 comments on commit 3698c93

Please sign in to comment.