From 00c62eddf4d60898f14559327970a24916de26c0 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Wed, 20 Oct 2021 08:52:12 +0000 Subject: [PATCH] Add RTC_PT_GUARDED_BY to sdp_handler_ As suggested in another review. Also add one more guard, and some commentary. Bug: None Change-Id: I9b84453ff2533fe01d157fe84f07405d352e1dc7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235820 Reviewed-by: Niels Moller Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#35245} --- pc/peer_connection.cc | 1 + pc/peer_connection.h | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index eb153eb58c..0ca18aaf35 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -2880,6 +2880,7 @@ bool PeerConnection::ShouldFireNegotiationNeededEvent(uint32_t event_id) { } void PeerConnection::RequestUsagePatternReportForTesting() { + RTC_DCHECK_RUN_ON(signaling_thread()); message_handler_.RequestUsagePatternReport( [this]() { RTC_DCHECK_RUN_ON(signaling_thread()); diff --git a/pc/peer_connection.h b/pc/peer_connection.h index 6e8666872d..7326bccd10 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -288,6 +288,7 @@ class PeerConnection : public PeerConnectionInternal, } sigslot::signal1& SignalSctpDataChannelCreated() override { + RTC_DCHECK_RUN_ON(signaling_thread()); return data_channel_controller_.SignalSctpDataChannelCreated(); } @@ -676,7 +677,7 @@ class PeerConnection : public PeerConnectionInternal, // The machinery for handling offers and answers. Const after initialization. std::unique_ptr sdp_handler_ - RTC_GUARDED_BY(signaling_thread()); + RTC_GUARDED_BY(signaling_thread()) RTC_PT_GUARDED_BY(signaling_thread()); const bool dtls_enabled_; @@ -684,20 +685,24 @@ class PeerConnection : public PeerConnectionInternal, bool return_histogram_very_quickly_ RTC_GUARDED_BY(signaling_thread()) = false; + // The DataChannelController is accessed from both the signaling thread + // and networking thread. It is a thread-aware object. DataChannelController data_channel_controller_; // Machinery for handling messages posted to oneself - PeerConnectionMessageHandler message_handler_; + PeerConnectionMessageHandler message_handler_ + RTC_GUARDED_BY(signaling_thread()); // Administration of senders, receivers and transceivers // Accessed on both signaling and network thread. Const after Initialize(). std::unique_ptr rtp_manager_; - rtc::WeakPtrFactory weak_factory_; - // Did the connectionState ever change to `connected`? // Used to gather metrics only the first such state change. bool was_ever_connected_ RTC_GUARDED_BY(signaling_thread()) = false; + + // This variable needs to be the last one in the class. + rtc::WeakPtrFactory weak_factory_; }; } // namespace webrtc