Commit acfbcb21 authored by lambroslambrou's avatar lambroslambrou Committed by Commit bot

Handle exception writing to Chromoting host's stdin.

The linux_me2me_host script launches the host process, then writes the
JSON config to the child's stdin. If the host process dies before the
data is written to stdin, an IOError (EPIPE) exception is raised. This
CL handles the exception and retries launching the host, instead of
exiting the script.

To test this, I added a time.sleep(5) call between launching the
host and writing the config to stdin. This allowed me enough time to
simulate the error by killing the host process.

BUG=473441

Review URL: https://codereview.chromium.org/1138613002

Cr-Commit-Position: refs/heads/master@{#329273}
parent 7e15c6af
...@@ -509,8 +509,19 @@ class Desktop: ...@@ -509,8 +509,19 @@ class Desktop:
logging.info(args) logging.info(args)
if not self.host_proc.pid: if not self.host_proc.pid:
raise Exception("Could not start Chrome Remote Desktop host") raise Exception("Could not start Chrome Remote Desktop host")
self.host_proc.stdin.write(json.dumps(host_config.data))
self.host_proc.stdin.close() try:
self.host_proc.stdin.write(json.dumps(host_config.data))
self.host_proc.stdin.flush()
except IOError as e:
# This can occur in rare situations, for example, if the machine is
# heavily loaded and the host process dies quickly (maybe if the X
# connection failed), the host process might be gone before this code
# writes to the host's stdin. Catch and log the exception, allowing
# the process to be retried instead of exiting the script completely.
logging.error("Failed writing to host's stdin: " + str(e))
finally:
self.host_proc.stdin.close()
def get_daemon_proc(): def get_daemon_proc():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment