Patchwork D687: ssh: fix flakey ssh errors on BSD systems

login
register
mail settings
Submitter phabricator
Date Sept. 12, 2017, 1:17 a.m.
Message ID <4639d8c189f8754c9be18cc34960f9b8@localhost.localdomain>
Download mbox | patch
Permalink /patch/23808/
State Not Applicable
Headers show

Comments

phabricator - Sept. 12, 2017, 1:17 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc037fd655b47: ssh: fix flakey ssh errors on BSD systems (authored by durham).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D687?vs=1743&id=1746

REVISION DETAIL
  https://phab.mercurial-scm.org/D687

AFFECTED FILES
  mercurial/sshpeer.py

CHANGE DETAILS




To: durham, #hg-reviewers, quark, durin42
Cc: durin42, quark, mercurial-devel

Patch

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -203,23 +203,33 @@ 
         self._pipei = doublepipe(self.ui, self._pipei, self._pipee)
         self._pipeo = doublepipe(self.ui, self._pipeo, self._pipee)
 
-        # skip any noise generated by remote shell
-        self._callstream("hello")
-        r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40)))
+        def badresponse():
+            self._abort(error.RepoError(_('no suitable response from '
+                                          'remote hg')))
+
+        try:
+            # skip any noise generated by remote shell
+            self._callstream("hello")
+            r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40)))
+        except IOError:
+            badresponse()
+
         lines = ["", "dummy"]
         max_noise = 500
         while lines[-1] and max_noise:
-            l = r.readline()
-            self._readerr()
-            if lines[-1] == "1\n" and l == "\n":
-                break
-            if l:
-                self.ui.debug("remote: ", l)
-            lines.append(l)
-            max_noise -= 1
+            try:
+                l = r.readline()
+                self._readerr()
+                if lines[-1] == "1\n" and l == "\n":
+                    break
+                if l:
+                    self.ui.debug("remote: ", l)
+                lines.append(l)
+                max_noise -= 1
+            except IOError:
+                badresponse()
         else:
-            self._abort(error.RepoError(_('no suitable response from '
-                                          'remote hg')))
+            badresponse()
 
         self._caps = set()
         for l in reversed(lines):