From 89aad9e16814ac610a2b6409a803c584076c49b0 Mon Sep 17 00:00:00 2001 From: Elad Alon Date: Wed, 18 Apr 2018 14:02:21 +0200 Subject: [PATCH] Remove the limit on concurrent RtcEventLogImpl instances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The limit was introduced to avoid spawning too many threads. It had the downside that the peer connections which have an associated RtcEventLogImpl instance, are not necessarily those which we wish to log. After this CL, it becomes the responsibility of the application hosting WebRTC to limit the number of peer connections to a number which it can support, including thread resources. Bug: webrtc:9046 Change-Id: I7444a6020dd51583c666285655af986def53faa4 Reviewed-on: https://webrtc-review.googlesource.com/70661 Commit-Queue: Elad Alon Reviewed-by: Dino Radaković Reviewed-by: Björn Terelius Cr-Commit-Position: refs/heads/master@{#23019} --- logging/rtc_event_log/rtc_event_log_impl.cc | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/logging/rtc_event_log/rtc_event_log_impl.cc b/logging/rtc_event_log/rtc_event_log_impl.cc index 943d90b63e..74f88779ef 100644 --- a/logging/rtc_event_log/rtc_event_log_impl.cc +++ b/logging/rtc_event_log/rtc_event_log_impl.cc @@ -10,7 +10,6 @@ #include "logging/rtc_event_log/rtc_event_log.h" -#include #include #include #include @@ -41,11 +40,6 @@ constexpr size_t kMaxEventsInHistory = 10000; // to prevent an attack via unreasonable memory use. constexpr size_t kMaxEventsInConfigHistory = 1000; -// Observe a limit on the number of concurrent logs, so as not to run into -// OS-imposed limits on open files and/or threads/task-queues. -// TODO(eladalon): Known issue - there's a race over |rtc_event_log_count|. -std::atomic rtc_event_log_count(0); - // TODO(eladalon): This class exists because C++11 doesn't allow transferring a // unique_ptr to a lambda (a copy constructor is required). We should get // rid of this when we move to C++14. @@ -160,9 +154,6 @@ RtcEventLogImpl::~RtcEventLogImpl() { // If we're logging to the output, this will stop that. Blocking function. StopLogging(); - - int count = std::atomic_fetch_sub(&rtc_event_log_count, 1) - 1; - RTC_DCHECK_GE(count, 0); } bool RtcEventLogImpl::StartLogging(std::unique_ptr output, @@ -370,17 +361,7 @@ std::unique_ptr RtcEventLog::Create( EncodingType encoding_type, std::unique_ptr task_queue) { #ifdef ENABLE_RTC_EVENT_LOG - // TODO(eladalon): Known issue - there's a race over |rtc_event_log_count|. - constexpr int kMaxLogCount = 5; - int count = 1 + std::atomic_fetch_add(&rtc_event_log_count, 1); - if (count > kMaxLogCount) { - RTC_LOG(LS_WARNING) << "Denied creation of additional WebRTC event logs. " - << count - 1 << " logs open already."; - std::atomic_fetch_sub(&rtc_event_log_count, 1); - return CreateNull(); - } - auto encoder = CreateEncoder(encoding_type); - return rtc::MakeUnique(std::move(encoder), + return rtc::MakeUnique(CreateEncoder(encoding_type), std::move(task_queue)); #else return CreateNull();