Repository: mesos Updated Branches: refs/heads/master f6d7cd6da -> 19cf3068b
Rewrote some comments in switchboard.cpp for clarity. Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/19cf3068 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/19cf3068 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/19cf3068 Branch: refs/heads/master Commit: 19cf3068b81355818a9c4cdb797883f2b73cdbce Parents: 6d19caa Author: Alexander Rukletsov <al...@apache.org> Authored: Wed Jan 17 15:25:46 2018 +0100 Committer: Alexander Rukletsov <al...@apache.org> Committed: Wed Jan 17 15:36:50 2018 +0100 ---------------------------------------------------------------------- src/slave/containerizer/mesos/io/switchboard.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/19cf3068/src/slave/containerizer/mesos/io/switchboard.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/mesos/io/switchboard.cpp b/src/slave/containerizer/mesos/io/switchboard.cpp index 34e1460..a1a50ce 100644 --- a/src/slave/containerizer/mesos/io/switchboard.cpp +++ b/src/slave/containerizer/mesos/io/switchboard.cpp @@ -1015,7 +1015,7 @@ private: bool waitForConnection; Option<Duration> heartbeatInterval; bool inputConnected; - bool redirectFinished; + bool redirectFinished; // Set when both stdout and stderr redirects finish. Future<unix::Socket> accept; Promise<Nothing> promise; Promise<Nothing> startRedirect; @@ -1223,8 +1223,10 @@ Future<Nothing> IOSwitchboardServerProcess::run() collect(stdoutRedirect, stderrRedirect) .then(defer(self(), [this]() { redirectFinished = true; - // If IO redirect is finished, we need to give a chance - // to send a http response for an input connection. + + // Postpone termination if input is connected. This gives us a chance + // to properly close the input connection and send an http response, + // see `attachContainerInput()`. if (!inputConnected) { terminate(self(), false); } @@ -1671,10 +1673,10 @@ Future<http::Response> IOSwitchboardServerProcess::attachContainerInput( // Reset `inputConnected` to allow future input connections. inputConnected = false; - // We only set `failure` if writing to `stdin` failed, in which - // case we want to terminate ourselves (after flushing any - // outstanding messages from our message queue). Also, if IO redirect - // is finished, we want to terminate ourselves. + // We only set `failure` if writing to `stdin` failed, in which case we + // want to terminate ourselves (after flushing any outstanding messages + // from our message queue). Also, if IO redirect has already finished, + // we can safely terminate. if (failure.isSome() || redirectFinished) { terminate(self(), false); }