mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vinodk...@apache.org
Subject git commit: Added missing stout/glog.hpp.
Date Sat, 16 Aug 2014 17:35:50 GMT
Repository: mesos
Updated Branches:
  refs/heads/master dd990c53c -> 0bc57b89a


Added missing stout/glog.hpp.


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

Branch: refs/heads/master
Commit: 0bc57b89a279df933439c075f929835db5404f34
Parents: dd990c5
Author: Vinod Kone <vinodkone@gmail.com>
Authored: Sat Aug 16 10:35:28 2014 -0700
Committer: Vinod Kone <vinodkone@gmail.com>
Committed: Sat Aug 16 10:35:28 2014 -0700

----------------------------------------------------------------------
 .../3rdparty/stout/include/stout/glog.hpp       | 94 ++++++++++++++++++++
 1 file changed, 94 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0bc57b89/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
new file mode 100644
index 0000000..5f763e5
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/glog.hpp
@@ -0,0 +1,94 @@
+/**
+ * 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)
+{
+  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);
+  }
+}
+
+} // 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_handler = internal::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";
+  }
+}
+
+#endif // __STOUT_GLOG_HPP__


Mime
View raw message