~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/medium.py

  • Committer: Robert Collins
  • Date: 2009-09-03 23:43:16 UTC
  • mfrom: (4634.6.17 2.0)
  • mto: This revision was merged to the branch mainline in revision 4671.
  • Revision ID: robertc@robertcollins.net-20090903234316-2wfb1eefkcx4qgl4
Merge 2.0, includes EINTR support for bzr://, and better stream representation with bzr:// streams.

Show diffs side-by-side

added added

removed removed

Lines of Context:
291
291
    def terminate_due_to_error(self):
292
292
        # TODO: This should log to a server log file, but no such thing
293
293
        # exists yet.  Andrew Bennetts 2006-09-29.
294
 
        self.socket.close()
 
294
        osutils.until_no_eintr(self.socket.close)
295
295
        self.finished = True
296
296
 
297
297
    def _write_out(self, bytes):
326
326
            bytes_to_read = protocol.next_read_size()
327
327
            if bytes_to_read == 0:
328
328
                # Finished serving this request.
329
 
                self._out.flush()
 
329
                osutils.until_no_eintr(self._out.flush)
330
330
                return
331
331
            bytes = self.read_bytes(bytes_to_read)
332
332
            if bytes == '':
333
333
                # Connection has been closed.
334
334
                self.finished = True
335
 
                self._out.flush()
 
335
                osutils.until_no_eintr(self._out.flush)
336
336
                return
337
337
            protocol.accept_bytes(bytes)
338
338
 
339
339
    def _read_bytes(self, desired_count):
340
 
        return self._in.read(desired_count)
 
340
        return osutils.until_no_eintr(self._in.read, desired_count)
341
341
 
342
342
    def terminate_due_to_error(self):
343
343
        # TODO: This should log to a server log file, but no such thing
344
344
        # exists yet.  Andrew Bennetts 2006-09-29.
345
 
        self._out.close()
 
345
        osutils.until_no_eintr(self._out.close)
346
346
        self.finished = True
347
347
 
348
348
    def _write_out(self, bytes):
349
 
        self._out.write(bytes)
 
349
        osutils.until_no_eintr(self._out.write, bytes)
350
350
 
351
351
 
352
352
class SmartClientMediumRequest(object):
712
712
 
713
713
    def _accept_bytes(self, bytes):
714
714
        """See SmartClientStreamMedium.accept_bytes."""
715
 
        self._writeable_pipe.write(bytes)
 
715
        osutils.until_no_eintr(self._writeable_pipe.write, bytes)
716
716
        self._report_activity(len(bytes), 'write')
717
717
 
718
718
    def _flush(self):
719
719
        """See SmartClientStreamMedium._flush()."""
720
 
        self._writeable_pipe.flush()
 
720
        osutils.until_no_eintr(self._writeable_pipe.flush)
721
721
 
722
722
    def _read_bytes(self, count):
723
723
        """See SmartClientStreamMedium._read_bytes."""
724
 
        bytes = self._readable_pipe.read(count)
 
724
        bytes = osutils.until_no_eintr(self._readable_pipe.read, count)
725
725
        self._report_activity(len(bytes), 'read')
726
726
        return bytes
727
727
 
765
765
    def _accept_bytes(self, bytes):
766
766
        """See SmartClientStreamMedium.accept_bytes."""
767
767
        self._ensure_connection()
768
 
        self._write_to.write(bytes)
 
768
        osutils.until_no_eintr(self._write_to.write, bytes)
769
769
        self._report_activity(len(bytes), 'write')
770
770
 
771
771
    def disconnect(self):
772
772
        """See SmartClientMedium.disconnect()."""
773
773
        if not self._connected:
774
774
            return
775
 
        self._read_from.close()
776
 
        self._write_to.close()
 
775
        osutils.until_no_eintr(self._read_from.close)
 
776
        osutils.until_no_eintr(self._write_to.close)
777
777
        self._ssh_connection.close()
778
778
        self._connected = False
779
779
 
802
802
        if not self._connected:
803
803
            raise errors.MediumNotConnected(self)
804
804
        bytes_to_read = min(count, _MAX_READ_SIZE)
805
 
        bytes = self._read_from.read(bytes_to_read)
 
805
        bytes = osutils.until_no_eintr(self._read_from.read, bytes_to_read)
806
806
        self._report_activity(len(bytes), 'read')
807
807
        return bytes
808
808
 
832
832
        """See SmartClientMedium.disconnect()."""
833
833
        if not self._connected:
834
834
            return
835
 
        self._socket.close()
 
835
        osutils.until_no_eintr(self._socket.close)
836
836
        self._socket = None
837
837
        self._connected = False
838
838