Skip to content

Commit 9118da9

Browse files
committed
handle SSL_ERROR_WANT_WRITE in SSLSocket.sendall
1 parent e26e817 commit 9118da9

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/wolfssl/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,17 @@ def sendall(self, data, flags=0):
520520
sent = 0
521521

522522
while sent < length:
523-
sent += self.write(data[sent:])
523+
ret = self.write(data[sent:])
524+
if (ret < 0):
525+
err = _lib.wolfSSL_get_error(self.native_object, 0)
526+
if err == _SSL_ERROR_WANT_WRITE:
527+
raise SSLWantWriteError()
528+
else:
529+
raise SSLError("wolfSSL_write error (%d)" % err)
530+
531+
sent += ret
524532

525-
return sent
533+
return None
526534

527535
def sendto(self, data, flags_or_addr, addr=None):
528536
# Ensures not to send unencrypted data trying to use this method
@@ -638,6 +646,7 @@ def unwrap(self):
638646
sock_type=self._sock.type,
639647
proto=self._sock.proto,
640648
fileno=self._sock.fileno())
649+
641650
sock.settimeout(self._sock.gettimeout())
642651
self._sock.detach()
643652

0 commit comments

Comments
 (0)