diff options
| author | Jakub Stasiak <jakub@stasiak.at> | 2015-11-11 00:11:02 +0100 |
|---|---|---|
| committer | Jakub Stasiak <jakub@stasiak.at> | 2015-11-11 00:25:00 +0100 |
| commit | 719e987c0de7f3c69f5b0fa6e51a65beba1068b8 (patch) | |
| tree | 1c79c03aacf62582c9de8bff83057781def06078 | |
| parent | da7f9732b6d9d52c8bca5cdbb536beb1fac14b44 (diff) | |
| download | eventlet-socket-send.tar.gz | |
greenio: Remove sendall-like semantincs from GreenSocket.sendsocket-send
When a socket timeout was set the sendall-like semantics was resulting
in losing information about sent data and raising socket.timeout exception.
The previous GreenSocket.send() implementation used to call fd.send() in a
loop until all data was sent. The issue would manifest if at least one
fd.send() call succeeded and was followed by a fd.send() call that would
block and a trampoline that timed out. The client code would see
socket.timeout being raised and would rightfully assume that no data was
sent which would be incorrect.
Discussed at https://github.com/eventlet/eventlet/issues/260.
| -rw-r--r-- | eventlet/greenio/base.py | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/eventlet/greenio/base.py b/eventlet/greenio/base.py index 18799af..ea091d4 100644 --- a/eventlet/greenio/base.py +++ b/eventlet/greenio/base.py @@ -351,28 +351,20 @@ class GreenSocket(object): if self.act_non_blocking: return fd.send(data, flags) - # blocking socket behavior - sends all, blocks if the buffer is full - total_sent = 0 - len_data = len(data) while 1: try: - total_sent += fd.send(data[total_sent:], flags) + return fd.send(data, flags) except socket.error as e: eno = get_errno(e) if eno == errno.ENOTCONN or eno not in SOCKET_BLOCKING: raise - if total_sent == len_data: - break - try: self._trampoline(self.fd, write=True, timeout=self.gettimeout(), timeout_exc=socket.timeout("timed out")) except IOClosed: raise socket.error(errno.ECONNRESET, 'Connection closed by another thread') - return total_sent - def sendall(self, data, flags=0): tail = self.send(data, flags) len_data = len(data) |
