##// END OF EJS Templates
sshpeer: defer pipe buffering and stderr sidechannel binding...
Gregory Szorc -
r36388:11ba1a96 default
parent child Browse files
Show More
@@ -156,13 +156,13 b' def _makeconnection(ui, sshcmd, args, re'
156 156 # move to threading.
157 157 stdin, stdout, stderr, proc = util.popen4(cmd, bufsize=0, env=sshenv)
158 158
159 stdout = doublepipe(ui, util.bufferedinputpipe(stdout), stderr)
160 stdin = doublepipe(ui, stdin, stderr)
161
162 159 return proc, stdin, stdout, stderr
163 160
164 161 def _performhandshake(ui, stdin, stdout, stderr):
165 162 def badresponse():
163 # Flush any output on stderr.
164 _forwardoutput(ui, stderr)
165
166 166 msg = _('no suitable response from remote hg')
167 167 hint = ui.config('ui', 'ssherrorhint')
168 168 raise error.RepoError(msg, hint=hint)
@@ -331,6 +331,9 b' def _performhandshake(ui, stdin, stdout,'
331 331 if not caps:
332 332 badresponse()
333 333
334 # Flush any output on stderr before proceeding.
335 _forwardoutput(ui, stderr)
336
334 337 return protoname, caps
335 338
336 339 class sshv1peer(wireproto.wirepeer):
@@ -347,6 +350,12 b' class sshv1peer(wireproto.wirepeer):'
347 350 # self._subprocess is unused. Keeping a handle on the process
348 351 # holds a reference and prevents it from being garbage collected.
349 352 self._subprocess = proc
353
354 # And we hook up our "doublepipe" wrapper to allow querying
355 # stderr any time we perform I/O.
356 stdout = doublepipe(ui, util.bufferedinputpipe(stdout), stderr)
357 stdin = doublepipe(ui, stdin, stderr)
358
350 359 self._pipeo = stdin
351 360 self._pipei = stdout
352 361 self._pipee = stderr
@@ -59,16 +59,20 b' class badpeer(httppeer.httppeer):'
59 59 def badmethod(self):
60 60 pass
61 61
62 class dummypipe(object):
63 def close(self):
64 pass
65
62 66 def main():
63 67 ui = uimod.ui()
64 68
65 69 checkobject(badpeer())
66 70 checkobject(httppeer.httppeer(ui, 'http://localhost'))
67 71 checkobject(localrepo.localpeer(dummyrepo()))
68 checkobject(sshpeer.sshv1peer(ui, 'ssh://localhost/foo', None, None, None,
69 None, None))
70 checkobject(sshpeer.sshv2peer(ui, 'ssh://localhost/foo', None, None, None,
71 None, None))
72 checkobject(sshpeer.sshv1peer(ui, 'ssh://localhost/foo', None, dummypipe(),
73 dummypipe(), None, None))
74 checkobject(sshpeer.sshv2peer(ui, 'ssh://localhost/foo', None, dummypipe(),
75 dummypipe(), None, None))
72 76 checkobject(bundlerepo.bundlepeer(dummyrepo()))
73 77 checkobject(statichttprepo.statichttppeer(dummyrepo()))
74 78 checkobject(unionrepo.unionpeer(dummyrepo()))
General Comments 0
You need to be logged in to leave comments. Login now