eventlet.green.ssl busywaiting on send.
Thanks to Joshua Kwan for discovering this and making sure it got fixed.
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -72,3 +72,4 @@ Thanks To
|
|||||||
* rfk, patch to get green zmq to respect noblock flag.
|
* rfk, patch to get green zmq to respect noblock flag.
|
||||||
* Soren Hansen, finding and fixing issue in subprocess (#77)
|
* Soren Hansen, finding and fixing issue in subprocess (#77)
|
||||||
* Stefano Rivera, making tests pass in absence of postgres (#78)
|
* Stefano Rivera, making tests pass in absence of postgres (#78)
|
||||||
|
* Joshua Kwan, fixing busy-wait in eventlet.green.ssl.
|
||||||
|
@@ -78,19 +78,18 @@ class GreenSSLSocket(__ssl.SSLSocket):
|
|||||||
return func(*a, **kw)
|
return func(*a, **kw)
|
||||||
except SSLError, exc:
|
except SSLError, exc:
|
||||||
if get_errno(exc) == SSL_ERROR_WANT_READ:
|
if get_errno(exc) == SSL_ERROR_WANT_READ:
|
||||||
trampoline(self,
|
trampoline(self,
|
||||||
read=True,
|
read=True,
|
||||||
timeout=self.gettimeout(),
|
timeout=self.gettimeout(),
|
||||||
timeout_exc=timeout_exc('timed out'))
|
timeout_exc=timeout_exc('timed out'))
|
||||||
elif get_errno(exc) == SSL_ERROR_WANT_WRITE:
|
elif get_errno(exc) == SSL_ERROR_WANT_WRITE:
|
||||||
trampoline(self,
|
trampoline(self,
|
||||||
write=True,
|
write=True,
|
||||||
timeout=self.gettimeout(),
|
timeout=self.gettimeout(),
|
||||||
timeout_exc=timeout_exc('timed out'))
|
timeout_exc=timeout_exc('timed out'))
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
"""Write DATA to the underlying SSL channel. Returns
|
"""Write DATA to the underlying SSL channel. Returns
|
||||||
number of bytes of DATA actually transmitted."""
|
number of bytes of DATA actually transmitted."""
|
||||||
@@ -101,38 +100,15 @@ class GreenSSLSocket(__ssl.SSLSocket):
|
|||||||
"""Read up to LEN bytes and return them.
|
"""Read up to LEN bytes and return them.
|
||||||
Return zero-length string on EOF."""
|
Return zero-length string on EOF."""
|
||||||
return self._call_trampolining(
|
return self._call_trampolining(
|
||||||
super(GreenSSLSocket, self).read,len)
|
super(GreenSSLSocket, self).read, len)
|
||||||
|
|
||||||
def send (self, data, flags=0):
|
def send (self, data, flags=0):
|
||||||
# *NOTE: gross, copied code from ssl.py becase it's not factored well enough to be used as-is
|
|
||||||
if self._sslobj:
|
if self._sslobj:
|
||||||
if flags != 0:
|
return self._call_trampolining(
|
||||||
raise ValueError(
|
super(GreenSSLSocket, self).send, data, flags)
|
||||||
"non-zero flags not allowed in calls to send() on %s" %
|
|
||||||
self.__class__)
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
v = self._sslobj.write(data)
|
|
||||||
except SSLError, e:
|
|
||||||
if get_errno(e) == SSL_ERROR_WANT_READ:
|
|
||||||
return 0
|
|
||||||
elif get_errno(e) == SSL_ERROR_WANT_WRITE:
|
|
||||||
return 0
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
return v
|
|
||||||
else:
|
else:
|
||||||
while True:
|
trampoline(self, write=True, timeout_exc=timeout_exc('timed out'))
|
||||||
try:
|
return socket.send(self, data, flags)
|
||||||
return socket.send(self, data, flags)
|
|
||||||
except orig_socket.error, e:
|
|
||||||
if self.act_non_blocking:
|
|
||||||
raise
|
|
||||||
if get_errno(e) == errno.EWOULDBLOCK or \
|
|
||||||
get_errno(e) == errno.ENOTCONN:
|
|
||||||
return 0
|
|
||||||
raise
|
|
||||||
|
|
||||||
def sendto (self, data, addr, flags=0):
|
def sendto (self, data, addr, flags=0):
|
||||||
# *NOTE: gross, copied code from ssl.py becase it's not factored well enough to be used as-is
|
# *NOTE: gross, copied code from ssl.py becase it's not factored well enough to be used as-is
|
||||||
|
Reference in New Issue
Block a user