##// END OF EJS Templates
wireprotoserver: ability to run an SSH server until an event is set...
Gregory Szorc -
r36540:e7411fb7 default
parent child Browse files
Show More
@@ -9,6 +9,7 b' from __future__ import absolute_import'
9 import contextlib
9 import contextlib
10 import struct
10 import struct
11 import sys
11 import sys
12 import threading
12
13
13 from .i18n import _
14 from .i18n import _
14 from . import (
15 from . import (
@@ -373,7 +374,7 b' class sshv1protocolhandler(wireprototype'
373 class sshv2protocolhandler(sshv1protocolhandler):
374 class sshv2protocolhandler(sshv1protocolhandler):
374 """Protocol handler for version 2 of the SSH protocol."""
375 """Protocol handler for version 2 of the SSH protocol."""
375
376
376 def _runsshserver(ui, repo, fin, fout):
377 def _runsshserver(ui, repo, fin, fout, ev):
377 # This function operates like a state machine of sorts. The following
378 # This function operates like a state machine of sorts. The following
378 # states are defined:
379 # states are defined:
379 #
380 #
@@ -430,7 +431,7 b' def _runsshserver(ui, repo, fin, fout):'
430 proto = sshv1protocolhandler(ui, fin, fout)
431 proto = sshv1protocolhandler(ui, fin, fout)
431 protoswitched = False
432 protoswitched = False
432
433
433 while True:
434 while not ev.is_set():
434 if state == 'protov1-serving':
435 if state == 'protov1-serving':
435 # Commands are issued on new lines.
436 # Commands are issued on new lines.
436 request = fin.readline()[:-1]
437 request = fin.readline()[:-1]
@@ -601,5 +602,9 b' class sshserver(object):'
601 util.setbinary(self._fout)
602 util.setbinary(self._fout)
602
603
603 def serve_forever(self):
604 def serve_forever(self):
604 _runsshserver(self._ui, self._repo, self._fin, self._fout)
605 self.serveuntil(threading.Event())
605 sys.exit(0)
606 sys.exit(0)
607
608 def serveuntil(self, ev):
609 """Serve until a threading.Event is set."""
610 _runsshserver(self._ui, self._repo, self._fin, self._fout, ev)
General Comments 0
You need to be logged in to leave comments. Login now