You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2014/08/16 19:28:57 UTC
git commit: Moved
'mesos::internal::logging::installSignalFailureHandler()' to
stout/logging.hpp.
Repository: mesos
Updated Branches:
refs/heads/master 8cbb85c8a -> dd990c53c
Moved 'mesos::internal::logging::installSignalFailureHandler()' to stout/logging.hpp.
Review: https://reviews.apache.org/r/24753
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/dd990c53
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/dd990c53
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/dd990c53
Branch: refs/heads/master
Commit: dd990c53cc136fb92003b81eaa01f989ac5ae467
Parents: 8cbb85c
Author: Vinod Kone <vi...@gmail.com>
Authored: Fri Aug 15 16:26:35 2014 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Sat Aug 16 10:27:46 2014 -0700
----------------------------------------------------------------------
.../3rdparty/stout/include/Makefile.am | 1 +
.../libprocess/3rdparty/stout/tests/main.cpp | 7 ++-
3rdparty/libprocess/src/tests/main.cpp | 7 ++-
src/logging/logging.cpp | 59 ++------------------
src/tests/main.cpp | 2 +-
5 files changed, 15 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/dd990c53/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
index 6fa5b74..b18dbd3 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
@@ -19,6 +19,7 @@ nobase_include_HEADERS = \
stout/foreach.hpp \
stout/format.hpp \
stout/fs.hpp \
+ stout/glog.hpp \
stout/gtest.hpp \
stout/gzip.hpp \
stout/hashmap.hpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/dd990c53/3rdparty/libprocess/3rdparty/stout/tests/main.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/main.cpp b/3rdparty/libprocess/3rdparty/stout/tests/main.cpp
index 75dbfec..3bc26a3 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/main.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/main.cpp
@@ -4,14 +4,15 @@
#include <gtest/gtest.h>
+#include <stout/glog.hpp>
+
int main(int argc, char** argv)
{
// Initialize Google Mock/Test.
testing::InitGoogleMock(&argc, argv);
- // Handles SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, SIGTERM
- // by default.
- google::InstallFailureSignalHandler();
+ // Install default signal handler.
+ installFailureSignalHandler();
return RUN_ALL_TESTS();
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/dd990c53/3rdparty/libprocess/src/tests/main.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/main.cpp b/3rdparty/libprocess/src/tests/main.cpp
index 934cb47..b0592a3 100644
--- a/3rdparty/libprocess/src/tests/main.cpp
+++ b/3rdparty/libprocess/src/tests/main.cpp
@@ -8,6 +8,8 @@
#include <process/gtest.hpp>
#include <process/process.hpp>
+#include <stout/glog.hpp>
+
int main(int argc, char** argv)
{
// Initialize Google Mock/Test.
@@ -16,9 +18,8 @@ int main(int argc, char** argv)
// Initialize libprocess.
process::initialize();
- // Handles SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, SIGTERM
- // by default.
- google::InstallFailureSignalHandler();
+ // Install default signal handler.
+ installFailureSignalHandler();
// Add the libprocess test event listeners.
::testing::TestEventListeners& listeners =
http://git-wip-us.apache.org/repos/asf/mesos/blob/dd990c53/src/logging/logging.cpp
----------------------------------------------------------------------
diff --git a/src/logging/logging.cpp b/src/logging/logging.cpp
index b05a7e0..547673c 100644
--- a/src/logging/logging.cpp
+++ b/src/logging/logging.cpp
@@ -28,6 +28,7 @@
#include <stout/error.hpp>
#include <stout/exit.hpp>
+#include <stout/glog.hpp>
#include <stout/os.hpp>
#include <stout/path.hpp>
#include <stout/stringify.hpp>
@@ -65,33 +66,7 @@ namespace logging {
string argv0;
-// 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.
-void handler(int signal)
-{
- if (signal == SIGTERM) {
- RAW_LOG(WARNING, "Received signal SIGTERM; exiting.");
-
- // Setup the default handler for SIGTERM so that we don't print
- // a stack trace.
- struct sigaction action;
- memset(&action, 0, sizeof(action));
- sigemptyset(&action.sa_mask);
- action.sa_handler = SIG_DFL;
- sigaction(signal, &action, NULL);
- raise(signal);
- } else if (signal == SIGPIPE) {
- RAW_LOG(WARNING, "Received signal SIGPIPE; escalating to SIGABRT");
- raise(SIGABRT);
- } else {
- RAW_LOG(FATAL, "Unexpected signal in signal handler: %d", signal);
- }
-}
-
-
-google::LogSeverity getLogSeverity(const string& logging_level)
+google::LogSeverity getLogSeverity(const std::string& logging_level)
{
if (logging_level == "INFO") {
return google::INFO;
@@ -109,7 +84,7 @@ google::LogSeverity getLogSeverity(const string& logging_level)
void initialize(
const string& _argv0,
const Flags& flags,
- bool installFailureSignalHandler)
+ bool _installFailureSignalHandler)
{
static Once* initialized = new Once();
@@ -172,32 +147,8 @@ void initialize(
VLOG(1) << "Logging to " <<
(flags.log_dir.isSome() ? flags.log_dir.get() : "STDERR");
- if (installFailureSignalHandler) {
- // Handles SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, SIGTERM
- // by default.
- google::InstallFailureSignalHandler();
-
- // Set up our custom signal handlers.
- struct sigaction action;
- action.sa_handler = handler;
-
- // Do not block additional signals while in the handler.
- sigemptyset(&action.sa_mask);
- action.sa_flags = 0;
-
- // Set up the SIGPIPE signal handler to escalate to SIGABRT
- // in order to have the glog handler catch it and print all
- // of its lovely information.
- if (sigaction(SIGPIPE, &action, NULL) < 0) {
- PLOG(FATAL) << "Failed to set sigaction";
- }
-
- // We also do not want SIGTERM to dump a stacktrace, as this
- // can imply that we crashed, when we were in fact terminated
- // by user request.
- if (sigaction(SIGTERM, &action, NULL) < 0) {
- PLOG(FATAL) << "Failed to set sigaction";
- }
+ if (_installFailureSignalHandler) {
+ installFailureSignalHandler();
}
initialized->done();
http://git-wip-us.apache.org/repos/asf/mesos/blob/dd990c53/src/tests/main.cpp
----------------------------------------------------------------------
diff --git a/src/tests/main.cpp b/src/tests/main.cpp
index 442be51..32a2456 100644
--- a/src/tests/main.cpp
+++ b/src/tests/main.cpp
@@ -89,7 +89,7 @@ int main(int argc, char** argv)
}
// Initialize logging.
- logging::initialize(argv[0], flags);
+ logging::initialize(argv[0], flags, true);
// Initialize gmock/gtest.
testing::InitGoogleTest(&argc, argv);