You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jp...@apache.org on 2017/09/07 05:35:14 UTC
[4/6] mesos git commit: Enhanced async-signal safety of
`signalSafeWriteStatus` function.
Enhanced async-signal safety of `signalSafeWriteStatus` function.
Enhanced async-signal safety of `signalSafeWriteStatus` function.
Review: https://reviews.apache.org/r/61800/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/62631cab
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/62631cab
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/62631cab
Branch: refs/heads/master
Commit: 62631cab9661573d14be3e8696ff9e8d992a6952
Parents: d5b66d3
Author: Andrei Budnik <ab...@mesosphere.com>
Authored: Wed Sep 6 22:02:24 2017 -0700
Committer: James Peach <jp...@apache.org>
Committed: Wed Sep 6 22:02:24 2017 -0700
----------------------------------------------------------------------
src/slave/containerizer/mesos/launch.cpp | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/62631cab/src/slave/containerizer/mesos/launch.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/launch.cpp b/src/slave/containerizer/mesos/launch.cpp
index 0affcf5..d137298 100644
--- a/src/slave/containerizer/mesos/launch.cpp
+++ b/src/slave/containerizer/mesos/launch.cpp
@@ -25,6 +25,9 @@
#include <set>
#include <string>
+#include <glog/logging.h>
+#include <glog/raw_logging.h>
+
#include <process/subprocess.hpp>
#include <stout/foreach.hpp>
@@ -33,6 +36,8 @@
#include <stout/path.hpp>
#include <stout/unreachable.hpp>
+#include <stout/os/write.hpp>
+
#include <mesos/mesos.hpp>
#include <mesos/type_utils.hpp>
@@ -131,14 +136,15 @@ static void signalSafeWriteStatus(int status)
{
const string statusString = std::to_string(status);
- Try<Nothing> write = os::write(
- containerStatusFd.get(),
- statusString);
+ ssize_t result =
+ os::signal_safe::write(containerStatusFd.get(), statusString);
- if (write.isError()) {
- os::write(STDERR_FILENO,
- "Failed to write container status '" +
- statusString + "': " + ::strerror(errno));
+ if (result < 0) {
+ // NOTE: We use RAW_LOG instead of LOG because RAW_LOG doesn't
+ // allocate any memory or grab locks. And according to
+ // https://code.google.com/p/google-glog/issues/detail?id=161
+ // it should work in 'most' cases in signal handlers.
+ RAW_LOG(ERROR, "Failed to write container status '%d': %d", status, errno);
}
}