Skip to content

Commit 5828720

Browse files
committed
Socket: Fix hanging while TLS socket buffer is non-empty
1 parent a46a073 commit 5828720

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/drivers/Socket.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ def _read(self):
200200
"""Called by _select() when we can read data."""
201201
try:
202202
new_data = self.conn.recv(1024)
203+
if hasattr(self.conn, "pending") and self.conn.pending():
204+
# This is a TLS socket and there are decrypted bytes in the
205+
# buffer. We need to read them now, or we would not get them
206+
# until the next time select() returns this socket (which may
207+
# be in a very long time, as select() does not know recv() on
208+
# the TLS wrapper would not block).
209+
new_data += self.conn.recv(self.conn.pending())
203210
if not new_data:
204211
# Socket was closed
205212
self._handleSocketError(None)

0 commit comments

Comments
 (0)