~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: John Arbash Meinel
  • Date: 2011-01-12 21:06:32 UTC
  • mto: This revision was merged to the branch mainline in revision 5605.
  • Revision ID: john@arbash-meinel.com-20110112210632-t2926y70oe4igsul
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

Show diffs side-by-side

added added

removed removed

Lines of Context:
2001
2001
# data at once.
2002
2002
MAX_SOCKET_CHUNK = 64 * 1024
2003
2003
 
 
2004
_end_of_stream_errors = [errno.ECONNRESET]
 
2005
for _eno in ['WSAECONNRESET', 'WSAECONNABORTED']:
 
2006
    _eno = getattr(errno, _eno, None)
 
2007
    if _eno is not None:
 
2008
        _end_of_stream_errors.append(_eno)
 
2009
del _eno
 
2010
 
 
2011
 
2004
2012
def read_bytes_from_socket(sock, report_activity=None,
2005
2013
        max_read_size=MAX_SOCKET_CHUNK):
2006
2014
    """Read up to max_read_size of bytes from sock and notify of progress.
2014
2022
            bytes = sock.recv(max_read_size)
2015
2023
        except socket.error, e:
2016
2024
            eno = e.args[0]
2017
 
            if eno == getattr(errno, "WSAECONNRESET", errno.ECONNRESET):
 
2025
            if eno in _end_of_stream_errors:
2018
2026
                # The connection was closed by the other side.  Callers expect
2019
2027
                # an empty string to signal end-of-stream.
2020
2028
                return ""