[Cryptech-Commits] [sw/libhal] 02/02: Write to console socket and console log in parallel.
git at cryptech.is
git at cryptech.is
Sat Apr 15 22:35:53 UTC 2017
This is an automated email from the git hooks/post-receive script.
sra at hactrn.net pushed a commit to branch ksng
in repository sw/libhal.
commit a8c55772036369b67a871c35461cdf4bd6115ff1
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Sat Apr 15 18:32:42 2017 -0400
Write to console socket and console log in parallel.
We're using non-blocking I/O in any case, might as well take advantage
of it to keep console output a little smoother.
---
cryptech_muxd | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/cryptech_muxd b/cryptech_muxd
index c1cdf22..5b458a4 100755
--- a/cryptech_muxd
+++ b/cryptech_muxd
@@ -233,13 +233,13 @@ class CTYIOStream(SerialIOStream):
self.attached_cty.close()
return
try:
+ futures = []
if self.console_log is not None:
- self.console_log.write(buffer)
- except:
- pass
- try:
+ futures.append(self.console_log.write(buffer))
if self.attached_cty is not None:
- yield self.attached_cty.write(buffer)
+ futures.append(self.attached_cty.write(buffer))
+ if futures:
+ yield futures
except tornado.iostream.StreamClosedError:
pass
@@ -366,7 +366,7 @@ def main():
help = "log to file instead of stderr")
parser.add_argument("-L", "--console-log",
- type = argparse.FileType("w"),
+ type = argparse.FileType("a"),
help = "log console output to file")
parser.add_argument("-p", "--probe",
@@ -407,6 +407,11 @@ def main():
if args.probe is not None:
yield ProbeIOStream.run_probes(args)
+ if args.console_log is not None:
+ console_log = tornado.iostream.PipeIOStream(args.console_log.fileno())
+ else:
+ console_log = None
+
futures = []
if args.rpc_device is None:
@@ -419,7 +424,7 @@ def main():
if args.cty_device is None:
logger.warn("No CTY device found")
else:
- cty_stream = CTYIOStream(device = args.cty_device, console_log = args.console_log)
+ cty_stream = CTYIOStream(device = args.cty_device, console_log = console_log)
cty_server = CTYServer(cty_stream, args.cty_socket)
futures.append(cty_stream.cty_output_loop())
More information about the Commits
mailing list