##// 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 # move to threading.
156 # move to threading.
157 stdin, stdout, stderr, proc = util.popen4(cmd, bufsize=0, env=sshenv)
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 return proc, stdin, stdout, stderr
159 return proc, stdin, stdout, stderr
163
160
164 def _performhandshake(ui, stdin, stdout, stderr):
161 def _performhandshake(ui, stdin, stdout, stderr):
165 def badresponse():
162 def badresponse():
163 # Flush any output on stderr.
164 _forwardoutput(ui, stderr)
165
166 msg = _('no suitable response from remote hg')
166 msg = _('no suitable response from remote hg')
167 hint = ui.config('ui', 'ssherrorhint')
167 hint = ui.config('ui', 'ssherrorhint')
168 raise error.RepoError(msg, hint=hint)
168 raise error.RepoError(msg, hint=hint)
@@ -331,6 +331,9 b' def _performhandshake(ui, stdin, stdout,'
331 if not caps:
331 if not caps:
332 badresponse()
332 badresponse()
333
333
334 # Flush any output on stderr before proceeding.
335 _forwardoutput(ui, stderr)
336
334 return protoname, caps
337 return protoname, caps
335
338
336 class sshv1peer(wireproto.wirepeer):
339 class sshv1peer(wireproto.wirepeer):
@@ -347,6 +350,12 b' class sshv1peer(wireproto.wirepeer):'
347 # self._subprocess is unused. Keeping a handle on the process
350 # self._subprocess is unused. Keeping a handle on the process
348 # holds a reference and prevents it from being garbage collected.
351 # holds a reference and prevents it from being garbage collected.
349 self._subprocess = proc
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 self._pipeo = stdin
359 self._pipeo = stdin
351 self._pipei = stdout
360 self._pipei = stdout
352 self._pipee = stderr
361 self._pipee = stderr
@@ -59,16 +59,20 b' class badpeer(httppeer.httppeer):'
59 def badmethod(self):
59 def badmethod(self):
60 pass
60 pass
61
61
62 class dummypipe(object):
63 def close(self):
64 pass
65
62 def main():
66 def main():
63 ui = uimod.ui()
67 ui = uimod.ui()
64
68
65 checkobject(badpeer())
69 checkobject(badpeer())
66 checkobject(httppeer.httppeer(ui, 'http://localhost'))
70 checkobject(httppeer.httppeer(ui, 'http://localhost'))
67 checkobject(localrepo.localpeer(dummyrepo()))
71 checkobject(localrepo.localpeer(dummyrepo()))
68 checkobject(sshpeer.sshv1peer(ui, 'ssh://localhost/foo', None, None, None,
72 checkobject(sshpeer.sshv1peer(ui, 'ssh://localhost/foo', None, dummypipe(),
69 None, None))
73 dummypipe(), None, None))
70 checkobject(sshpeer.sshv2peer(ui, 'ssh://localhost/foo', None, None, None,
74 checkobject(sshpeer.sshv2peer(ui, 'ssh://localhost/foo', None, dummypipe(),
71 None, None))
75 dummypipe(), None, None))
72 checkobject(bundlerepo.bundlepeer(dummyrepo()))
76 checkobject(bundlerepo.bundlepeer(dummyrepo()))
73 checkobject(statichttprepo.statichttppeer(dummyrepo()))
77 checkobject(statichttprepo.statichttppeer(dummyrepo()))
74 checkobject(unionrepo.unionpeer(dummyrepo()))
78 checkobject(unionrepo.unionpeer(dummyrepo()))
General Comments 0
You need to be logged in to leave comments. Login now