~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: John Arbash Meinel
  • Date: 2012-09-19 07:58:27 UTC
  • mfrom: (6437.63.9 2.5)
  • mto: This revision was merged to the branch mainline in revision 6563.
  • Revision ID: john@arbash-meinel.com-20120919075827-36b2b042kiaps0d3
Merge bzr-2.5.2 into trunk to get the fixes for ConnectionReset.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2086
2086
# data at once.
2087
2087
MAX_SOCKET_CHUNK = 64 * 1024
2088
2088
 
2089
 
_end_of_stream_errors = [errno.ECONNRESET]
 
2089
_end_of_stream_errors = [errno.ECONNRESET, errno.EPIPE, errno.EINVAL]
2090
2090
for _eno in ['WSAECONNRESET', 'WSAECONNABORTED']:
2091
2091
    _eno = getattr(errno, _eno, None)
2092
2092
    if _eno is not None:
2158
2158
    while sent_total < byte_count:
2159
2159
        try:
2160
2160
            sent = sock.send(buffer(bytes, sent_total, MAX_SOCKET_CHUNK))
2161
 
        except socket.error, e:
 
2161
        except (socket.error, IOError), e:
 
2162
            if e.args[0] in _end_of_stream_errors:
 
2163
                raise errors.ConnectionReset(
 
2164
                    "Error trying to write to socket", e)
2162
2165
            if e.args[0] != errno.EINTR:
2163
2166
                raise
2164
2167
        else:
 
2168
            if sent == 0:
 
2169
                raise errors.ConnectionReset('Sending to %s returned 0 bytes'
 
2170
                                             % (sock,))
2165
2171
            sent_total += sent
2166
 
            report_activity(sent, 'write')
 
2172
            if report_activity is not None:
 
2173
                report_activity(sent, 'write')
2167
2174
 
2168
2175
 
2169
2176
def connect_socket(address):