~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

(jameinel) Treat socket.error(EPIPE) as a ConnectionReset (bug #1047325) so
 that clients will properly reconnect. (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2064
2064
# data at once.
2065
2065
MAX_SOCKET_CHUNK = 64 * 1024
2066
2066
 
2067
 
_end_of_stream_errors = [errno.ECONNRESET]
 
2067
_end_of_stream_errors = [errno.ECONNRESET, errno.EPIPE, errno.EINVAL]
2068
2068
for _eno in ['WSAECONNRESET', 'WSAECONNABORTED']:
2069
2069
    _eno = getattr(errno, _eno, None)
2070
2070
    if _eno is not None:
2136
2136
    while sent_total < byte_count:
2137
2137
        try:
2138
2138
            sent = sock.send(buffer(bytes, sent_total, MAX_SOCKET_CHUNK))
2139
 
        except socket.error, e:
 
2139
        except (socket.error, IOError), e:
 
2140
            if e.args[0] in _end_of_stream_errors:
 
2141
                raise errors.ConnectionReset(
 
2142
                    "Error trying to write to socket", e)
2140
2143
            if e.args[0] != errno.EINTR:
2141
2144
                raise
2142
2145
        else: