D2461: wireprotoserver: ability to run an SSH server until an event is set
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Thu Mar 1 21:30:30 UTC 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGe7411fb7ba7f: wireprotoserver: ability to run an SSH server until an event is set (authored by indygreg, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D2461?vs=6134&id=6278
REVISION DETAIL
https://phab.mercurial-scm.org/D2461
AFFECTED FILES
mercurial/wireprotoserver.py
CHANGE DETAILS
diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -9,6 +9,7 @@
import contextlib
import struct
import sys
+import threading
from .i18n import _
from . import (
@@ -373,7 +374,7 @@
class sshv2protocolhandler(sshv1protocolhandler):
"""Protocol handler for version 2 of the SSH protocol."""
-def _runsshserver(ui, repo, fin, fout):
+def _runsshserver(ui, repo, fin, fout, ev):
# This function operates like a state machine of sorts. The following
# states are defined:
#
@@ -430,7 +431,7 @@
proto = sshv1protocolhandler(ui, fin, fout)
protoswitched = False
- while True:
+ while not ev.is_set():
if state == 'protov1-serving':
# Commands are issued on new lines.
request = fin.readline()[:-1]
@@ -601,5 +602,9 @@
util.setbinary(self._fout)
def serve_forever(self):
- _runsshserver(self._ui, self._repo, self._fin, self._fout)
+ self.serveuntil(threading.Event())
sys.exit(0)
+
+ def serveuntil(self, ev):
+ """Serve until a threading.Event is set."""
+ _runsshserver(self._ui, self._repo, self._fin, self._fout, ev)
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list