Rev 5600: Consider WSAECONNABORTED to be an end-of-stream as well as WSAECONNRESET. in http://bazaar.launchpad.net/~jameinel/bzr/2.3-connection-reset-581311
John Arbash Meinel
john at arbash-meinel.com
Wed Jan 12 21:06:38 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/2.3-connection-reset-581311
------------------------------------------------------------
revno: 5600
revision-id: john at arbash-meinel.com-20110112210632-t2926y70oe4igsul
parent: pqm at pqm.ubuntu.com-20110112172132-p7n9cxhslpn6svhh
fixes bug(s): https://launchpad.net/bugs/581311
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.3-connection-reset-581311
timestamp: Wed 2011-01-12 15:06:32 -0600
message:
Consider WSAECONNABORTED to be an end-of-stream as well as WSAECONNRESET.
We don't have any other way to use WSAECONNABORTED, so just treat it the same.
bug #581311
-------------- next part --------------
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2011-01-12 00:58:05 +0000
+++ b/bzrlib/osutils.py 2011-01-12 21:06:32 +0000
@@ -2001,6 +2001,14 @@
# data at once.
MAX_SOCKET_CHUNK = 64 * 1024
+_end_of_stream_errors = [errno.ECONNRESET]
+for _eno in ['WSAECONNRESET', 'WSAECONNABORTED']:
+ _eno = getattr(errno, _eno, None)
+ if _eno is not None:
+ _end_of_stream_errors.append(_eno)
+del _eno
+
+
def read_bytes_from_socket(sock, report_activity=None,
max_read_size=MAX_SOCKET_CHUNK):
"""Read up to max_read_size of bytes from sock and notify of progress.
@@ -2014,7 +2022,7 @@
bytes = sock.recv(max_read_size)
except socket.error, e:
eno = e.args[0]
- if eno == getattr(errno, "WSAECONNRESET", errno.ECONNRESET):
+ if eno in _end_of_stream_errors:
# The connection was closed by the other side. Callers expect
# an empty string to signal end-of-stream.
return ""
More information about the bazaar-commits
mailing list