From 3cb525b378fd9cb683b19b0d5f18946a85fdef34 Mon Sep 17 00:00:00 2001 From: Markus Handell Date: Thu, 16 Jul 2020 16:16:09 +0200 Subject: [PATCH] Rename CriticalSection to RecursiveCriticalSection. This name change communicates that the recursive critical section should not be used for new code. The relevant files are renamed rtc_base/critical_section* -> rtc_base/deprecated/recursive_critical_section* Bug: webrtc:11567 Change-Id: I73483a1c5e59c389407a981efbfc2cfe76ccdb43 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179483 Commit-Queue: Markus Handell Reviewed-by: Niels Moller Reviewed-by: Danil Chapovalov Reviewed-by: Tommi Reviewed-by: Mirko Bonadei Cr-Commit-Position: refs/heads/master@{#31754} --- call/rtp_stream_receiver_controller.h | 4 +-- .../win/dxgi_duplicator_controller.h | 4 +-- modules/pacing/paced_sender.h | 4 +-- modules/utility/source/process_thread_impl.h | 5 ++-- pc/jsep_transport.h | 2 +- rtc_base/BUILD.gn | 7 ++--- .../recursive_critical_section.cc} | 19 ++++++------- .../recursive_critical_section.h} | 28 +++++++++++-------- .../recursive_critical_section_unittest.cc} | 18 ++++++------ rtc_base/deprecated/signal_thread.h | 4 +-- rtc_base/physical_socket_server.cc | 2 +- rtc_base/physical_socket_server.h | 6 ++-- rtc_base/thread.cc | 8 +++--- rtc_base/thread.h | 8 +++--- rtc_base/virtual_socket_server.cc | 2 +- rtc_base/virtual_socket_server.h | 6 ++-- sdk/objc/components/audio/RTCAudioSession.mm | 4 +-- test/network/network_emulation.h | 2 +- 18 files changed, 68 insertions(+), 65 deletions(-) rename rtc_base/{critical_section.cc => deprecated/recursive_critical_section.cc} (91%) rename rtc_base/{critical_section.h => deprecated/recursive_critical_section.h} (79%) rename rtc_base/{critical_section_unittest.cc => deprecated/recursive_critical_section_unittest.cc} (95%) diff --git a/call/rtp_stream_receiver_controller.h b/call/rtp_stream_receiver_controller.h index 045af3cf8d..62447aa521 100644 --- a/call/rtp_stream_receiver_controller.h +++ b/call/rtp_stream_receiver_controller.h @@ -14,7 +14,7 @@ #include "call/rtp_demuxer.h" #include "call/rtp_stream_receiver_controller_interface.h" -#include "rtc_base/critical_section.h" +#include "rtc_base/deprecated/recursive_critical_section.h" namespace webrtc { @@ -63,7 +63,7 @@ class RtpStreamReceiverController // to be called on the same thread, and OnRtpPacket to be called // by a single, but possibly distinct, thread. But applications not // using Call may have use threads differently. - rtc::CriticalSection lock_; + rtc::RecursiveCriticalSection lock_; RtpDemuxer demuxer_ RTC_GUARDED_BY(&lock_); }; diff --git a/modules/desktop_capture/win/dxgi_duplicator_controller.h b/modules/desktop_capture/win/dxgi_duplicator_controller.h index a24e9781b3..b6f8e78649 100644 --- a/modules/desktop_capture/win/dxgi_duplicator_controller.h +++ b/modules/desktop_capture/win/dxgi_duplicator_controller.h @@ -25,7 +25,7 @@ #include "modules/desktop_capture/win/dxgi_adapter_duplicator.h" #include "modules/desktop_capture/win/dxgi_context.h" #include "modules/desktop_capture/win/dxgi_frame.h" -#include "rtc_base/critical_section.h" +#include "rtc_base/deprecated/recursive_critical_section.h" namespace webrtc { @@ -219,7 +219,7 @@ class DxgiDuplicatorController { std::atomic_int refcount_; // This lock must be locked whenever accessing any of the following objects. - rtc::CriticalSection lock_; + rtc::RecursiveCriticalSection lock_; // A self-incremented integer to compare with the one in Context. It ensures // a Context instance is always initialized after DxgiDuplicatorController. diff --git a/modules/pacing/paced_sender.h b/modules/pacing/paced_sender.h index cc83b403ba..d255efdc3b 100644 --- a/modules/pacing/paced_sender.h +++ b/modules/pacing/paced_sender.h @@ -32,7 +32,7 @@ #include "modules/rtp_rtcp/include/rtp_packet_sender.h" #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" #include "modules/utility/include/process_thread.h" -#include "rtc_base/critical_section.h" +#include "rtc_base/deprecated/recursive_critical_section.h" #include "rtc_base/thread_annotations.h" namespace webrtc { @@ -157,7 +157,7 @@ class PacedSender : public Module, PacedSender* const delegate_; } module_proxy_{this}; - rtc::CriticalSection critsect_; + rtc::RecursiveCriticalSection critsect_; const PacingController::ProcessMode process_mode_; PacingController pacing_controller_ RTC_GUARDED_BY(critsect_); diff --git a/modules/utility/source/process_thread_impl.h b/modules/utility/source/process_thread_impl.h index 24a72d91f5..ed9f5c3bfc 100644 --- a/modules/utility/source/process_thread_impl.h +++ b/modules/utility/source/process_thread_impl.h @@ -20,7 +20,7 @@ #include "api/task_queue/queued_task.h" #include "modules/include/module.h" #include "modules/utility/include/process_thread.h" -#include "rtc_base/critical_section.h" +#include "rtc_base/deprecated/recursive_critical_section.h" #include "rtc_base/event.h" #include "rtc_base/location.h" #include "rtc_base/platform_thread.h" @@ -92,7 +92,8 @@ class ProcessThreadImpl : public ProcessThread { // issues, but I haven't figured out what they are, if there are alignment // requirements for mutexes on Mac or if there's something else to it. // So be careful with changing the layout. - rtc::CriticalSection lock_; // Used to guard modules_, tasks_ and stop_. + rtc::RecursiveCriticalSection + lock_; // Used to guard modules_, tasks_ and stop_. rtc::ThreadChecker thread_checker_; rtc::Event wake_up_; diff --git a/pc/jsep_transport.h b/pc/jsep_transport.h index 2ba4416665..11c8168d9e 100644 --- a/pc/jsep_transport.h +++ b/pc/jsep_transport.h @@ -316,7 +316,7 @@ class JsepTransport : public sigslot::has_slots<> { const rtc::Thread* const network_thread_; // Critical scope for fields accessed off-thread // TODO(https://bugs.webrtc.org/10300): Stop doing this. - rtc::CriticalSection accessor_lock_; + rtc::RecursiveCriticalSection accessor_lock_; const std::string mid_; // needs-ice-restart bit as described in JSEP. bool needs_ice_restart_ RTC_GUARDED_BY(accessor_lock_) = false; diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index 5ad55988e9..73bca85efa 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -170,8 +170,8 @@ rtc_source_set("refcount") { rtc_library("criticalsection") { sources = [ - "critical_section.cc", - "critical_section.h", + "deprecated/recursive_critical_section.cc", + "deprecated/recursive_critical_section.h", ] deps = [ ":atomicops", @@ -179,7 +179,6 @@ rtc_library("criticalsection") { ":macromagic", ":platform_thread_types", "synchronization:yield", - "system:rtc_export", "system:unused", ] } @@ -1181,7 +1180,7 @@ if (rtc_include_tests) { "byte_order_unittest.cc", "checks_unittest.cc", "copy_on_write_buffer_unittest.cc", - "critical_section_unittest.cc", + "deprecated/recursive_critical_section_unittest.cc", "event_tracer_unittest.cc", "event_unittest.cc", "logging_unittest.cc", diff --git a/rtc_base/critical_section.cc b/rtc_base/deprecated/recursive_critical_section.cc similarity index 91% rename from rtc_base/critical_section.cc rename to rtc_base/deprecated/recursive_critical_section.cc index 1f68299aab..068b9aa808 100644 --- a/rtc_base/critical_section.cc +++ b/rtc_base/deprecated/recursive_critical_section.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "rtc_base/critical_section.h" +#include "rtc_base/deprecated/recursive_critical_section.h" #include @@ -18,8 +18,6 @@ #include "rtc_base/synchronization/yield.h" #include "rtc_base/system/unused.h" -// TODO(tommi): Split this file up to per-platform implementation files. - #if RTC_DCHECK_IS_ON #define RTC_CS_DEBUG_CODE(x) x #else // !RTC_DCHECK_IS_ON @@ -28,7 +26,7 @@ namespace rtc { -CriticalSection::CriticalSection() { +RecursiveCriticalSection::RecursiveCriticalSection() { #if defined(WEBRTC_WIN) InitializeCriticalSection(&crit_); #elif defined(WEBRTC_POSIX) @@ -57,7 +55,7 @@ CriticalSection::CriticalSection() { #endif } -CriticalSection::~CriticalSection() { +RecursiveCriticalSection::~RecursiveCriticalSection() { #if defined(WEBRTC_WIN) DeleteCriticalSection(&crit_); #elif defined(WEBRTC_POSIX) @@ -71,7 +69,7 @@ CriticalSection::~CriticalSection() { #endif } -void CriticalSection::Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION() { +void RecursiveCriticalSection::Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION() { #if defined(WEBRTC_WIN) EnterCriticalSection(&crit_); #elif defined(WEBRTC_POSIX) @@ -130,7 +128,8 @@ void CriticalSection::Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION() { #endif } -bool CriticalSection::TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) { +bool RecursiveCriticalSection::TryEnter() const + RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) { #if defined(WEBRTC_WIN) return TryEnterCriticalSection(&crit_) != FALSE; #elif defined(WEBRTC_POSIX) @@ -163,7 +162,7 @@ bool CriticalSection::TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) { #endif } -void CriticalSection::Leave() const RTC_UNLOCK_FUNCTION() { +void RecursiveCriticalSection::Leave() const RTC_UNLOCK_FUNCTION() { RTC_DCHECK(CurrentThreadIsOwner()); #if defined(WEBRTC_WIN) LeaveCriticalSection(&crit_); @@ -191,7 +190,7 @@ void CriticalSection::Leave() const RTC_UNLOCK_FUNCTION() { #endif } -bool CriticalSection::CurrentThreadIsOwner() const { +bool RecursiveCriticalSection::CurrentThreadIsOwner() const { #if defined(WEBRTC_WIN) // OwningThread has type HANDLE but actually contains the Thread ID: // http://stackoverflow.com/questions/12675301/why-is-the-owningthread-member-of-critical-section-of-type-handle-when-it-is-de @@ -210,7 +209,7 @@ bool CriticalSection::CurrentThreadIsOwner() const { #endif } -CritScope::CritScope(const CriticalSection* cs) : cs_(cs) { +CritScope::CritScope(const RecursiveCriticalSection* cs) : cs_(cs) { cs_->Enter(); } CritScope::~CritScope() { diff --git a/rtc_base/critical_section.h b/rtc_base/deprecated/recursive_critical_section.h similarity index 79% rename from rtc_base/critical_section.h rename to rtc_base/deprecated/recursive_critical_section.h index af16861447..c044c732b9 100644 --- a/rtc_base/critical_section.h +++ b/rtc_base/deprecated/recursive_critical_section.h @@ -8,13 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef RTC_BASE_CRITICAL_SECTION_H_ -#define RTC_BASE_CRITICAL_SECTION_H_ +#ifndef RTC_BASE_DEPRECATED_RECURSIVE_CRITICAL_SECTION_H_ +#define RTC_BASE_DEPRECATED_RECURSIVE_CRITICAL_SECTION_H_ -#include "rtc_base/checks.h" #include "rtc_base/constructor_magic.h" #include "rtc_base/platform_thread_types.h" -#include "rtc_base/system/rtc_export.h" #include "rtc_base/thread_annotations.h" #if defined(WEBRTC_WIN) @@ -43,13 +41,18 @@ namespace rtc { +// NOTE: This class is deprecated. Please use webrtc::Mutex instead! +// Search using https://www.google.com/?q=recursive+lock+considered+harmful +// to find the reasons. +// // Locking methods (Enter, TryEnter, Leave)are const to permit protecting -// members inside a const context without requiring mutable CriticalSections -// everywhere. CriticalSection is reentrant lock. -class RTC_LOCKABLE RTC_EXPORT CriticalSection { +// members inside a const context without requiring mutable +// RecursiveCriticalSections everywhere. RecursiveCriticalSection is +// reentrant lock. +class RTC_LOCKABLE RecursiveCriticalSection { public: - CriticalSection(); - ~CriticalSection(); + RecursiveCriticalSection(); + ~RecursiveCriticalSection(); void Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION(); bool TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true); @@ -87,14 +90,15 @@ class RTC_LOCKABLE RTC_EXPORT CriticalSection { // CritScope, for serializing execution through a scope. class RTC_SCOPED_LOCKABLE CritScope { public: - explicit CritScope(const CriticalSection* cs) RTC_EXCLUSIVE_LOCK_FUNCTION(cs); + explicit CritScope(const RecursiveCriticalSection* cs) + RTC_EXCLUSIVE_LOCK_FUNCTION(cs); ~CritScope() RTC_UNLOCK_FUNCTION(); private: - const CriticalSection* const cs_; + const RecursiveCriticalSection* const cs_; RTC_DISALLOW_COPY_AND_ASSIGN(CritScope); }; } // namespace rtc -#endif // RTC_BASE_CRITICAL_SECTION_H_ +#endif // RTC_BASE_DEPRECATED_RECURSIVE_CRITICAL_SECTION_H_ diff --git a/rtc_base/critical_section_unittest.cc b/rtc_base/deprecated/recursive_critical_section_unittest.cc similarity index 95% rename from rtc_base/critical_section_unittest.cc rename to rtc_base/deprecated/recursive_critical_section_unittest.cc index 52d0a8f865..22c2655b3d 100644 --- a/rtc_base/critical_section_unittest.cc +++ b/rtc_base/deprecated/recursive_critical_section_unittest.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "rtc_base/critical_section.h" +#include "rtc_base/deprecated/recursive_critical_section.h" #include #include @@ -124,7 +124,7 @@ class RTC_LOCKABLE CriticalSectionLock { void Unlock() RTC_UNLOCK_FUNCTION() { cs_.Leave(); } private: - CriticalSection cs_; + RecursiveCriticalSection cs_; }; template @@ -183,7 +183,7 @@ class AtomicOpRunner : public RunnerBase { } private: - CriticalSection all_values_crit_; + RecursiveCriticalSection all_values_crit_; Verifier verifier_; }; @@ -282,7 +282,7 @@ TEST(AtomicOpsTest, CompareAndSwap) { EXPECT_EQ(1, runner.shared_value()); } -TEST(CriticalSectionTest, Basic) { +TEST(RecursiveCriticalSectionTest, Basic) { // Create and start lots of threads. LockRunner runner; std::vector> threads; @@ -320,7 +320,7 @@ class PerfTestData { private: uint8_t cache_line_barrier_1_[64]; - CriticalSection lock_; + RecursiveCriticalSection lock_; uint8_t cache_line_barrier_2_[64]; int64_t my_counter_ = 0; const int expected_count_; @@ -372,7 +372,7 @@ class PerfTestThread { // user 1m20.575s // sys 3m48.872s // Unit test output: -// [ OK ] CriticalSectionTest.Performance (294375 ms) +// [ OK ] RecursiveCriticalSectionTest.Performance (294375 ms) // // Native mutex implementation using first fit policy (current macOS default): // Approximate CPU usage: @@ -380,7 +380,7 @@ class PerfTestThread { // user 0m12.738s // sys 0m31.207s // Unit test output: -// [ OK ] CriticalSectionTest.Performance (11444 ms) +// [ OK ] RecursiveCriticalSectionTest.Performance (11444 ms) // // Special partially spin lock based implementation: // Approximate CPU usage: @@ -388,10 +388,10 @@ class PerfTestThread { // user 0m3.014s // sys 0m4.495s // Unit test output: -// [ OK ] CriticalSectionTest.Performance (1885 ms) +// [ OK ] RecursiveCriticalSectionTest.Performance (1885 ms) // // The test is disabled by default to avoid unecessarily loading the bots. -TEST(CriticalSectionTest, DISABLED_Performance) { +TEST(RecursiveCriticalSectionTest, DISABLED_Performance) { PerfTestThread threads[8]; Event event; diff --git a/rtc_base/deprecated/signal_thread.h b/rtc_base/deprecated/signal_thread.h index 54f2ba48c2..3612f5a1ca 100644 --- a/rtc_base/deprecated/signal_thread.h +++ b/rtc_base/deprecated/signal_thread.h @@ -15,7 +15,7 @@ #include "rtc_base/checks.h" #include "rtc_base/constructor_magic.h" -#include "rtc_base/critical_section.h" +#include "rtc_base/deprecated/recursive_critical_section.h" #include "rtc_base/deprecation.h" #include "rtc_base/message_handler.h" #include "rtc_base/third_party/sigslot/sigslot.h" @@ -149,7 +149,7 @@ class DEPRECATED_SignalThread : public sigslot::has_slots<>, Thread* main_; Worker worker_; - CriticalSection cs_; + RecursiveCriticalSection cs_; State state_ RTC_GUARDED_BY(cs_); int refcount_ RTC_GUARDED_BY(cs_); bool destroy_called_ RTC_GUARDED_BY(cs_) = false; diff --git a/rtc_base/physical_socket_server.cc b/rtc_base/physical_socket_server.cc index 3a95331669..05b32557be 100644 --- a/rtc_base/physical_socket_server.cc +++ b/rtc_base/physical_socket_server.cc @@ -955,7 +955,7 @@ class EventDispatcher : public Dispatcher { PhysicalSocketServer* ss_; int afd_[2]; bool fSignaled_; - CriticalSection crit_; + RecursiveCriticalSection crit_; }; #endif // WEBRTC_POSIX diff --git a/rtc_base/physical_socket_server.h b/rtc_base/physical_socket_server.h index e21e53b8ec..7eaf590e3a 100644 --- a/rtc_base/physical_socket_server.h +++ b/rtc_base/physical_socket_server.h @@ -21,7 +21,7 @@ #include #include -#include "rtc_base/critical_section.h" +#include "rtc_base/deprecated/recursive_critical_section.h" #include "rtc_base/net_helpers.h" #include "rtc_base/socket_server.h" #include "rtc_base/system/rtc_export.h" @@ -111,7 +111,7 @@ class RTC_EXPORT PhysicalSocketServer : public SocketServer { DispatcherSet pending_remove_dispatchers_ RTC_GUARDED_BY(crit_); bool processing_dispatchers_ RTC_GUARDED_BY(crit_) = false; Signaler* signal_wakeup_; // Assigned in constructor only - CriticalSection crit_; + RecursiveCriticalSection crit_; #if defined(WEBRTC_WIN) const WSAEVENT socket_ev_; #endif @@ -191,7 +191,7 @@ class PhysicalSocket : public AsyncSocket, public sigslot::has_slots<> { SOCKET s_; bool udp_; int family_ = 0; - CriticalSection crit_; + RecursiveCriticalSection crit_; int error_ RTC_GUARDED_BY(crit_); ConnState state_; AsyncResolver* resolver_; diff --git a/rtc_base/thread.cc b/rtc_base/thread.cc index 651f95f3eb..2882f50da3 100644 --- a/rtc_base/thread.cc +++ b/rtc_base/thread.cc @@ -31,7 +31,7 @@ #include "absl/algorithm/container.h" #include "rtc_base/atomic_ops.h" #include "rtc_base/checks.h" -#include "rtc_base/critical_section.h" +#include "rtc_base/deprecated/recursive_critical_section.h" #include "rtc_base/logging.h" #include "rtc_base/null_socket_server.h" #include "rtc_base/synchronization/sequence_checker.h" @@ -88,8 +88,8 @@ class MessageHandlerWithTask final : public MessageHandler { class RTC_SCOPED_LOCKABLE MarkProcessingCritScope { public: - MarkProcessingCritScope(const CriticalSection* cs, size_t* processing) - RTC_EXCLUSIVE_LOCK_FUNCTION(cs) + MarkProcessingCritScope(const RecursiveCriticalSection* cs, + size_t* processing) RTC_EXCLUSIVE_LOCK_FUNCTION(cs) : cs_(cs), processing_(processing) { cs_->Enter(); *processing_ += 1; @@ -101,7 +101,7 @@ class RTC_SCOPED_LOCKABLE MarkProcessingCritScope { } private: - const CriticalSection* const cs_; + const RecursiveCriticalSection* const cs_; size_t* processing_; RTC_DISALLOW_COPY_AND_ASSIGN(MarkProcessingCritScope); diff --git a/rtc_base/thread.h b/rtc_base/thread.h index 8147490a3b..27a5b7b510 100644 --- a/rtc_base/thread.h +++ b/rtc_base/thread.h @@ -29,7 +29,7 @@ #include "api/task_queue/queued_task.h" #include "api/task_queue/task_queue_base.h" #include "rtc_base/constructor_magic.h" -#include "rtc_base/critical_section.h" +#include "rtc_base/deprecated/recursive_critical_section.h" #include "rtc_base/location.h" #include "rtc_base/message_handler.h" #include "rtc_base/platform_thread_types.h" @@ -140,7 +140,7 @@ class RTC_EXPORT ThreadManager { // Methods that don't modify the list of message queues may be called in a // re-entrant fashion. "processing_" keeps track of the depth of re-entrant // calls. - CriticalSection crit_; + RecursiveCriticalSection crit_; size_t processing_ RTC_GUARDED_BY(crit_) = 0; #if RTC_DCHECK_IS_ON // Represents all thread seand actions by storing all send targets per thread. @@ -531,7 +531,7 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase { friend class ScopedDisallowBlockingCalls; - CriticalSection* CritForTest() { return &crit_; } + RecursiveCriticalSection* CritForTest() { return &crit_; } private: class QueuedTaskHandler final : public MessageHandler { @@ -582,7 +582,7 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase { std::vector allowed_threads_ RTC_GUARDED_BY(this); bool invoke_policy_enabled_ RTC_GUARDED_BY(this) = false; #endif - CriticalSection crit_; + RecursiveCriticalSection crit_; bool fInitialized_; bool fDestroyed_; diff --git a/rtc_base/virtual_socket_server.cc b/rtc_base/virtual_socket_server.cc index 454aa05315..3d412d66cc 100644 --- a/rtc_base/virtual_socket_server.cc +++ b/rtc_base/virtual_socket_server.cc @@ -19,7 +19,7 @@ #include "absl/algorithm/container.h" #include "rtc_base/checks.h" -#include "rtc_base/critical_section.h" +#include "rtc_base/deprecated/recursive_critical_section.h" #include "rtc_base/fake_clock.h" #include "rtc_base/logging.h" #include "rtc_base/physical_socket_server.h" diff --git a/rtc_base/virtual_socket_server.h b/rtc_base/virtual_socket_server.h index dc7fe106a1..84f8fb1bdc 100644 --- a/rtc_base/virtual_socket_server.h +++ b/rtc_base/virtual_socket_server.h @@ -17,7 +17,7 @@ #include "rtc_base/checks.h" #include "rtc_base/constructor_magic.h" -#include "rtc_base/critical_section.h" +#include "rtc_base/deprecated/recursive_critical_section.h" #include "rtc_base/event.h" #include "rtc_base/fake_clock.h" #include "rtc_base/message_handler.h" @@ -295,7 +295,7 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> { std::map alternative_address_mapping_; std::unique_ptr delay_dist_; - CriticalSection delay_crit_; + RecursiveCriticalSection delay_crit_; double drop_prob_; bool sending_blocked_ = false; @@ -380,7 +380,7 @@ class VirtualSocket : public AsyncSocket, bool ready_to_send_ = true; // Critical section to protect the recv_buffer and queue_ - CriticalSection crit_; + RecursiveCriticalSection crit_; // Network model that enforces bandwidth and capacity constraints NetworkQueue network_; diff --git a/sdk/objc/components/audio/RTCAudioSession.mm b/sdk/objc/components/audio/RTCAudioSession.mm index 74b57acd61..520b2d1d37 100644 --- a/sdk/objc/components/audio/RTCAudioSession.mm +++ b/sdk/objc/components/audio/RTCAudioSession.mm @@ -16,7 +16,7 @@ #include "rtc_base/atomic_ops.h" #include "rtc_base/checks.h" -#include "rtc_base/critical_section.h" +#include "rtc_base/deprecated/recursive_critical_section.h" #import "RTCAudioSessionConfiguration.h" #import "base/RTCLogging.h" @@ -35,7 +35,7 @@ NSString * const kRTCAudioSessionOutputVolumeSelector = @"outputVolume"; // TODO(tkchin): Consider more granular locking. We're not expecting a lot of // lock contention so coarse locks should be fine for now. @implementation RTC_OBJC_TYPE (RTCAudioSession) { - rtc::CriticalSection _crit; + rtc::RecursiveCriticalSection _crit; AVAudioSession *_session; volatile int _activationCount; volatile int _lockRecursionCount; diff --git a/test/network/network_emulation.h b/test/network/network_emulation.h index 75e9c2c78a..eadd8b2eaf 100644 --- a/test/network/network_emulation.h +++ b/test/network/network_emulation.h @@ -168,7 +168,7 @@ class EmulatedEndpointImpl : public EmulatedEndpoint { uint16_t NextPort() RTC_EXCLUSIVE_LOCKS_REQUIRED(receiver_lock_); void UpdateReceiveStats(const EmulatedIpPacket& packet); - rtc::CriticalSection receiver_lock_; + rtc::RecursiveCriticalSection receiver_lock_; rtc::ThreadChecker enabled_state_checker_; uint64_t id_;