Commit 22871d81 authored by Denis Bilenko's avatar Denis Bilenko

ssl: fix unwrap() method not to raise SSLError("read operation timeout")

--HG--
extra : transplant_source : %1BC%DB%8C%C3K%94%B3%B6%AC6%8A%1A%25oKX%D3%97B
parent c410c7f8
...@@ -286,9 +286,39 @@ class SSLSocket(socket): ...@@ -286,9 +286,39 @@ class SSLSocket(socket):
else: else:
return 0 return 0
def _sslobj_shutdown(self):
while True:
try:
return self._sslobj.shutdown()
except SSLError, ex:
if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
return ''
elif ex.args[0] == SSL_ERROR_WANT_READ:
if self.timeout == 0.0:
raise
sys.exc_clear()
try:
wait_read(self.fileno(), timeout=self.timeout, timeout_exc=_SSLErrorReadTimeout, event=self._read_event)
except socket_error, ex:
if ex[0] == EBADF:
return ''
raise
elif ex.args[0] == SSL_ERROR_WANT_WRITE:
if self.timeout == 0.0:
raise
sys.exc_clear()
try:
wait_write(self.fileno(), timeout=self.timeout, timeout_exc=_SSLErrorWriteTimeout, event=self._write_event)
except socket_error, ex:
if ex[0] == EBADF:
return ''
raise
else:
raise
def unwrap(self): def unwrap(self):
if self._sslobj: if self._sslobj:
s = self._sslobj.shutdown() s = self._sslobj_shutdown()
self._sslobj = None self._sslobj = None
return socket(_sock=s) return socket(_sock=s)
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment