From ec22183f4368bbd6f0e6938417ce4ddfa7566485 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Thu, 21 Nov 2019 10:07:57 +0100 Subject: [PATCH] Revert lock for logging to CriticalSection This reverts commit I5b9d9036aa90eb0c652f6b17ea1162dea0362640 using spin lock (Global lock) for highly used lock may cause deadlock on ios Bug: None Change-Id: Ia7594d665bc17717299245b1a6cfcff18f273e77 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160200 Reviewed-by: Stefan Holmer Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/master@{#29857} --- rtc_base/logging.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rtc_base/logging.cc b/rtc_base/logging.cc index 158be33b4d..ff10c9868a 100644 --- a/rtc_base/logging.cc +++ b/rtc_base/logging.cc @@ -68,7 +68,7 @@ const char* FilenameFromPath(const char* file) { } // Global lock for log subsystem, only needed to serialize access to streams_. -ABSL_CONST_INIT GlobalLock g_log_crit; +CriticalSection g_log_crit; } // namespace // Inefficient default implementation, override is recommended. @@ -201,7 +201,7 @@ LogMessage::~LogMessage() { #endif } - GlobalLockScope cs(&g_log_crit); + CritScope cs(&g_log_crit); for (LogSink* entry = streams_; entry != nullptr; entry = entry->next_) { if (severity_ >= entry->min_severity_) { #if defined(WEBRTC_ANDROID) @@ -250,7 +250,7 @@ void LogMessage::LogTimestamps(bool on) { void LogMessage::LogToDebug(LoggingSeverity min_sev) { g_dbg_sev = min_sev; - GlobalLockScope cs(&g_log_crit); + CritScope cs(&g_log_crit); UpdateMinLogSeverity(); } @@ -259,7 +259,7 @@ void LogMessage::SetLogToStderr(bool log_to_stderr) { } int LogMessage::GetLogToStream(LogSink* stream) { - GlobalLockScope cs(&g_log_crit); + CritScope cs(&g_log_crit); LoggingSeverity sev = LS_NONE; for (LogSink* entry = streams_; entry != nullptr; entry = entry->next_) { if (stream == nullptr || stream == entry) { @@ -270,7 +270,7 @@ int LogMessage::GetLogToStream(LogSink* stream) { } void LogMessage::AddLogToStream(LogSink* stream, LoggingSeverity min_sev) { - GlobalLockScope cs(&g_log_crit); + CritScope cs(&g_log_crit); stream->min_severity_ = min_sev; stream->next_ = streams_; streams_ = stream; @@ -278,7 +278,7 @@ void LogMessage::AddLogToStream(LogSink* stream, LoggingSeverity min_sev) { } void LogMessage::RemoveLogToStream(LogSink* stream) { - GlobalLockScope cs(&g_log_crit); + CritScope cs(&g_log_crit); for (LogSink** entry = &streams_; *entry != nullptr; entry = &(*entry)->next_) { if (*entry == stream) { @@ -447,7 +447,7 @@ bool LogMessage::IsNoop(LoggingSeverity severity) { // TODO(tommi): We're grabbing this lock for every LogMessage instance that // is going to be logged. This introduces unnecessary synchronization for // a feature that's mostly used for testing. - GlobalLockScope cs(&g_log_crit); + CritScope cs(&g_log_crit); return streams_ == nullptr; }