From 58287207d7df846ed97c8e6ba9a0a0cb5dfb27e0 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 29 Sep 2023 15:25:30 +0200 Subject: [PATCH] Socket: Fix hanging while TLS socket buffer is non-empty --- src/drivers/Socket.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/drivers/Socket.py b/src/drivers/Socket.py index 3e73ac655..23d242153 100644 --- a/src/drivers/Socket.py +++ b/src/drivers/Socket.py @@ -200,6 +200,13 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin): """Called by _select() when we can read data.""" try: new_data = self.conn.recv(1024) + if hasattr(self.conn, "pending") and self.conn.pending(): + # This is a TLS socket and there are decrypted bytes in the + # buffer. We need to read them now, or we would not get them + # until the next time select() returns this socket (which may + # be in a very long time, as select() does not know recv() on + # the TLS wrapper would not block). + new_data += self.conn.recv(self.conn.pending()) if not new_data: # Socket was closed self._handleSocketError(None)