Patchwork [stable] ssh: fix flakey ssh errors on BSD systems

login
register
mail settings
Submitter Augie Fackler
Date Sept. 15, 2017, 9:32 p.m.
Message ID <7d51e7a6ca176e3de6a8.1505511179@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/23920/
State Accepted
Headers show

Comments

Augie Fackler - Sept. 15, 2017, 9:32 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1505170758 25200
#      Mon Sep 11 15:59:18 2017 -0700
# Branch stable
# Node ID 7d51e7a6ca176e3de6a8f1c4881afacbf4687487
# Parent  91f0677dc92028e4778f58adf365940fbed48fa9
ssh: fix flakey ssh errors on BSD systems

This is a trivial backport of c037fd655b47 performed by
augie@google.com, but the change is still really Durham's not mine, so
I [augie] am leaving him as the author.
via Mercurial-devel - Sept. 15, 2017, 9:42 p.m.
On Fri, Sep 15, 2017 at 2:32 PM, Augie Fackler <raf@durin42.com> wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1505170758 25200
> #      Mon Sep 11 15:59:18 2017 -0700
> # Branch stable
> # Node ID 7d51e7a6ca176e3de6a8f1c4881afacbf4687487
> # Parent  91f0677dc92028e4778f58adf365940fbed48fa9
> ssh: fix flakey ssh errors on BSD systems

Queued, thanks.

Patch

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -190,23 +190,33 @@  class sshpeer(wireproto.wirepeer):
         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):