Sort threading for sctp_mid_ variable
Split the sctp_mid_ variable into two variables,
sctp_mid_n_ and sctp_mid_s_, each of which is only accessed
by one thread.
Bug: webrtc:9987
Change-Id: I4dce944b920f4698e2606a7b85776791cbf55c28
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168243
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30503}
diff --git a/pc/peer_connection.h b/pc/peer_connection.h
index 475029a..822930b 100644
--- a/pc/peer_connection.h
+++ b/pc/peer_connection.h
@@ -321,7 +321,7 @@
void RequestUsagePatternReportForTesting();
absl::optional<std::string> sctp_mid() {
RTC_DCHECK_RUN_ON(signaling_thread());
- return sctp_mid_;
+ return sctp_mid_s_;
}
protected:
@@ -1330,9 +1330,11 @@
// Note: this is used as the data channel MID by both SCTP and data channel
// transports. It is set when either transport is initialized and unset when
// both transports are deleted.
- absl::optional<std::string>
- sctp_mid_; // TODO(bugs.webrtc.org/9987): Accessed on both signaling
- // and network thread.
+ // There is one copy on the signaling thread and another copy on the
+ // networking thread. Changes are always initiated from the signaling
+ // thread, but applied first on the networking thread via an invoke().
+ absl::optional<std::string> sctp_mid_s_ RTC_GUARDED_BY(signaling_thread());
+ absl::optional<std::string> sctp_mid_n_ RTC_GUARDED_BY(network_thread());
// Whether this peer is the caller. Set when the local description is applied.
absl::optional<bool> is_caller_ RTC_GUARDED_BY(signaling_thread());