~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/medium.py

Merge the fix for bug #819604 into trunk, resolve conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
881
881
        """
882
882
        return SmartClientStreamMediumRequest(self)
883
883
 
 
884
    def reset(self):
 
885
        """We have been disconnected, reset current state.
 
886
 
 
887
        This resets things like _current_request and connected state.
 
888
        """
 
889
        self.disconnect()
 
890
        self._current_request = None
 
891
 
884
892
 
885
893
class SmartSimplePipesClientMedium(SmartClientStreamMedium):
886
894
    """A client medium using simple pipes.
895
903
 
896
904
    def _accept_bytes(self, bytes):
897
905
        """See SmartClientStreamMedium.accept_bytes."""
898
 
        self._writeable_pipe.write(bytes)
 
906
        try:
 
907
            self._writeable_pipe.write(bytes)
 
908
        except IOError, e:
 
909
            if e.errno in (errno.EINVAL, errno.EPIPE):
 
910
                raise errors.ConnectionReset(
 
911
                    "Error trying to write to subprocess:\n%s" % (e,))
 
912
            raise
899
913
        self._report_activity(len(bytes), 'write')
900
914
 
901
915
    def _flush(self):
902
916
        """See SmartClientStreamMedium._flush()."""
 
917
        # Note: If flush were to fail, we'd like to raise ConnectionReset, etc.
 
918
        #       However, testing shows that even when the child process is
 
919
        #       gone, this doesn't error.
903
920
        self._writeable_pipe.flush()
904
921
 
905
922
    def _read_bytes(self, count):
924
941
 
925
942
class SmartSSHClientMedium(SmartClientStreamMedium):
926
943
    """A client medium using SSH.
927
 
    
928
 
    It delegates IO to a SmartClientSocketMedium or
 
944
 
 
945
    It delegates IO to a SmartSimplePipesClientMedium or
929
946
    SmartClientAlreadyConnectedSocketMedium (depending on platform).
930
947
    """
931
948
 
1164
1181
        This invokes self._medium._flush to ensure all bytes are transmitted.
1165
1182
        """
1166
1183
        self._medium._flush()
1167
 
 
1168