~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Patch Queue Manager
  • Date: 2012-09-19 08:27:25 UTC
  • mfrom: (6562.1.1 2.6-merge-up-2.5)
  • Revision ID: pqm@pqm.ubuntu.com-20120919082725-dzvmca37zj5xx2hh
(jam) Merge bzr-2.5.2-dev into bzr trunk to get the ConnectionReset
        fixes.

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):