Repository: mesos
Updated Branches:
  refs/heads/master 358901a6d -> 6af543211


Fixed signal handling for stout.

Review: https://reviews.apache.org/r/25126


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1f695fa2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1f695fa2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1f695fa2

Branch: refs/heads/master
Commit: 1f695fa2dd676a66c8dbe1d3d41fe4ecc958b5ea
Parents: 358901a
Author: Vinod Kone <[email protected]>
Authored: Wed Aug 27 15:47:27 2014 -0700
Committer: Vinod Kone <[email protected]>
Committed: Wed Aug 27 15:48:07 2014 -0700

----------------------------------------------------------------------
 .../3rdparty/stout/include/Makefile.am          |   1 -
 .../3rdparty/stout/include/stout/glog.hpp       | 104 -------------------
 .../3rdparty/stout/include/stout/os/signals.hpp |  12 +++
 .../libprocess/3rdparty/stout/tests/main.cpp    |   8 +-
 4 files changed, 14 insertions(+), 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1f695fa2/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 b18dbd3..6fa5b74 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
@@ -19,7 +19,6 @@ 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/1f695fa2/3rdparty/libprocess/3rdparty/stout/include/stout/glog.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/glog.hpp 
b/3rdparty/libprocess/3rdparty/stout/include/stout/glog.hpp
deleted file mode 100644
index cec7f4d..0000000
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/glog.hpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __STOUT_GLOG_HPP__
-#define __STOUT_GLOG_HPP__
-
-#include <signal.h> // For sigaction(), sigemptyset().
-#include <string.h> // For strsignal().
-
-#include <glog/logging.h>
-#include <glog/raw_logging.h>
-
-#include <string>
-
-#include <glog/logging.h> // Includes LOG(*), PLOG(*), CHECK, etc.
-
-// 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.
-namespace internal {
-
-inline void handler(int signal, siginfo_t *siginfo, void *context)
-{
-  if (signal == SIGTERM) {
-    if (siginfo->si_code == SI_USER ||
-        siginfo->si_code == SI_QUEUE ||
-        siginfo->si_code <= 0) {
-      RAW_LOG(WARNING, "Received signal SIGTERM from process %d of user %d; "
-                       "exiting", siginfo->si_pid, siginfo->si_uid);
-    } else {
-      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);
-  }
-}
-
-} // namespace internal {
-
-
-// Installs failure handlers for signals (SIGSEGV, SIGILL, SIGFPE, SIGABRT
-// and SIGBUS) to print stack traces.
-// NOTE: SIGPIPE is escalated to SIGABRT to get a stack trace.
-inline void installFailureSignalHandler()
-{
-  // Handles SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, SIGTERM
-  // by default.
-  google::InstallFailureSignalHandler();
-
-  // Set up our custom signal handlers.
-  struct sigaction action;
-  action.sa_sigaction = internal::handler;
-
-  // Do not block additional signals while in the handler.
-  sigemptyset(&action.sa_mask);
-
-  // The SA_SIGINFO flag tells sigaction() to use
-  // the sa_sigaction field, not sa_handler.
-  action.sa_flags = SA_SIGINFO;
-
-  // 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";
-  }
-}
-
-#endif // __STOUT_GLOG_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/1f695fa2/3rdparty/libprocess/3rdparty/stout/include/stout/os/signals.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/signals.hpp 
b/3rdparty/libprocess/3rdparty/stout/include/stout/os/signals.hpp
index f32130a..30232f5 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/signals.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/signals.hpp
@@ -17,12 +17,24 @@
 #include <errno.h>
 #include <pthread.h>
 #include <signal.h>
+#include <string.h>
 #include <unistd.h>
 
 namespace os {
 
 namespace signals {
 
+// Resets the signal handler to the default handler of the signal.
+inline int reset(int signal)
+{
+  struct sigaction action;
+  memset(&action, 0, sizeof(action));
+  sigemptyset(&action.sa_mask);
+  action.sa_handler = SIG_DFL;
+  return sigaction(signal, &action, NULL);
+}
+
+
 // Returns true iff the signal is pending.
 inline bool pending(int signal)
 {

http://git-wip-us.apache.org/repos/asf/mesos/blob/1f695fa2/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 fa8093b..f5f20ee 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/main.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/main.cpp
@@ -4,17 +4,13 @@
 
 #include <gtest/gtest.h>
 
-#include <stout/glog.hpp>
-
 int main(int argc, char** argv)
 {
   // Initialize Google Mock/Test.
   testing::InitGoogleMock(&argc, argv);
 
-  // Install default signal handler.
-  // TODO(jieyu): We temporarily disable this since it causes some
-  // flaky tests. Re-enable it once we find the root cause.
-  installFailureSignalHandler();
+  // Install GLOG's signal handler.
+  google::InstallFailureSignalHandler();
 
   return RUN_ALL_TESTS();
 }

Reply via email to