[go: nahoru, domu]

Make POSIX SIGTERM/SIGINT/SIGHUP handler async signal safe.
* Don't use LOG/CHECK.  Replace with RAW_LOG/DCHECK (newly added to logging.h)
* Don't directly post a task to the UI loop.  Write to a magic pipe.  Read this from a separate thread which will post to a task to the UI loop.
BUG=http://crbug.com/29240

Review URL: http://codereview.chromium.org/460094

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34036 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/logging.h b/base/logging.h
index 4fbe4830..cac9ca34 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -772,6 +772,17 @@
 //       after this call.
 void CloseLogFile();
 
+// Async signal safe logging mechanism.
+void RawLog(int level, const char* message);
+
+#define RAW_LOG(level, message) logging::RawLog(logging::LOG_ ## level, message)
+
+#define RAW_CHECK(condition)                                                   \
+  do {                                                                         \
+    if (!(condition))                                                          \
+      logging::RawLog(logging::LOG_FATAL, "Check failed: " #condition "\n");   \
+  } while (0)
+
 }  // namespace logging
 
 // These functions are provided as a convenience for logging, which is where we