diff options
author | Rob Austein <sra@hactrn.net> | 2017-04-15 18:32:42 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2017-04-15 18:32:42 -0400 |
commit | a8c55772036369b67a871c35461cdf4bd6115ff1 (patch) | |
tree | 293e6c60a5aa4762abf22c35ad7a6e77529b80ef /cryptech_muxd | |
parent | 5357c6d04432c25945563bd71e74ebecb8290276 (diff) |
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.
Diffstat (limited to 'cryptech_muxd')
-rwxr-xr-x | cryptech_muxd | 19 |
1 files 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()) |