зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1865633
- Process HTTP/3 server output immediately, r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D194083
This commit is contained in:
Родитель
231bc44aa2
Коммит
fbad32a5f2
|
@ -1395,7 +1395,11 @@ class MochitestDesktop(object):
|
|||
serverOptions["isWin"] = mozinfo.isWin
|
||||
serverOptions["proxyPort"] = options.http3ServerPort
|
||||
env = test_environment(xrePath=options.xrePath, log=self.log)
|
||||
self.http3Server = Http3Server(serverOptions, env, self.log)
|
||||
serverEnv = env.copy()
|
||||
serverLog = env.get("MOZHTTP3_SERVER_LOG")
|
||||
if serverLog is not None:
|
||||
serverEnv["RUST_LOG"] = serverLog
|
||||
self.http3Server = Http3Server(serverOptions, serverEnv, self.log)
|
||||
self.http3Server.start()
|
||||
|
||||
port = self.http3Server.ports().get("MOZHTTP3_PORT_PROXY")
|
||||
|
|
|
@ -11,6 +11,7 @@ import time
|
|||
from argparse import Namespace
|
||||
from contextlib import contextmanager
|
||||
from subprocess import PIPE, Popen
|
||||
from threading import Thread
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
@ -52,6 +53,8 @@ class Http3Server(object):
|
|||
self._proxyPort = -1
|
||||
if options.get("proxyPort"):
|
||||
self._proxyPort = options["proxyPort"]
|
||||
self.outthread = None
|
||||
self.errthread = None
|
||||
|
||||
def ports(self):
|
||||
return self._ports
|
||||
|
@ -59,6 +62,17 @@ class Http3Server(object):
|
|||
def echConfig(self):
|
||||
return self._echConfig
|
||||
|
||||
def read_streams(self, name, proc, pipe):
|
||||
while True:
|
||||
line = pipe.readline()
|
||||
output = "stdout" if pipe == proc.stdout else "stderr"
|
||||
if line:
|
||||
self._log.info("server: %s [%s] %s" % (name, output, line))
|
||||
|
||||
# Check if process is dead
|
||||
if proc.poll() is not None:
|
||||
break
|
||||
|
||||
def start(self):
|
||||
if not os.path.exists(self._http3ServerPath):
|
||||
raise Exception("Http3 server not found at %s" % self._http3ServerPath)
|
||||
|
@ -107,6 +121,21 @@ class Http3Server(object):
|
|||
self._ports["MOZHTTP3_PORT_PROXY"] = searchObj.group(4)
|
||||
self._ports["MOZHTTP3_PORT_NO_RESPONSE"] = searchObj.group(5)
|
||||
self._echConfig = searchObj.group(6)
|
||||
name = "http3server"
|
||||
t1 = Thread(
|
||||
target=self.read_streams,
|
||||
args=(name, process, process.stdout),
|
||||
daemon=True
|
||||
)
|
||||
t1.start()
|
||||
t2 = Thread(
|
||||
target=self.read_streams,
|
||||
args=(name, process, process.stderr),
|
||||
daemon=True
|
||||
)
|
||||
t2.start()
|
||||
self.outthread = t1
|
||||
self.errthread = t2
|
||||
except OSError as e:
|
||||
# This occurs if the subprocess couldn't be started
|
||||
self._log.error("Could not run the http3 server: %s" % (str(e)))
|
||||
|
@ -129,17 +158,12 @@ class Http3Server(object):
|
|||
self._log.info("Killing proc")
|
||||
proc.kill()
|
||||
break
|
||||
|
||||
def dumpOutput(fd, label):
|
||||
firstTime = True
|
||||
for msg in fd:
|
||||
if firstTime:
|
||||
firstTime = False
|
||||
self._log.info("Process %s" % label)
|
||||
self._log.info(msg)
|
||||
|
||||
dumpOutput(proc.stdout, "stdout")
|
||||
dumpOutput(proc.stderr, "stderr")
|
||||
if self.outthread is not None:
|
||||
self.outthread.join()
|
||||
del self.outthread
|
||||
if self.errthread is not None:
|
||||
self.errthread.join()
|
||||
del self.errthread
|
||||
self._http3ServerProc = {}
|
||||
|
||||
|
||||
|
|
|
@ -1494,7 +1494,11 @@ class XPCShellTests(object):
|
|||
options["profilePath"] = dbPath
|
||||
options["isMochitest"] = False
|
||||
options["isWin"] = sys.platform == "win32"
|
||||
self.http3Server = Http3Server(options, self.env, self.log)
|
||||
serverEnv = self.env.copy()
|
||||
serverLog = self.env.get("MOZHTTP3_SERVER_LOG")
|
||||
if serverLog is not None:
|
||||
serverEnv["RUST_LOG"] = serverLog
|
||||
self.http3Server = Http3Server(options, serverEnv, self.log)
|
||||
self.http3Server.start()
|
||||
for key, value in self.http3Server.ports().items():
|
||||
self.env[key] = value
|
||||
|
|
Загрузка…
Ссылка в новой задаче