Stash away a pointer to the signaling thread.

This is to make sure that thread checks on the signaling thread inside
the ObserverAdapter, don't dereference the `channel_` object which
may have gone away.

(using No-try: true since the internal bots are behind)

No-try: True
Bug: webrtc:11547
Change-Id: I8f1dbf266cfc3f69fea8598a5db9baf82e4db0af
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/300601
Reviewed-by: Jeremy Leconte <jleconte@google.com>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39787}
This commit is contained in:
Tommi 2023-04-07 12:04:02 +02:00 committed by WebRTC LUCI CQ
parent f9e13f8813
commit 56577ccc8f

View File

@ -261,11 +261,14 @@ class SctpDataChannel::ObserverAdapter : public DataChannelObserver {
}));
}
rtc::Thread* signaling_thread() const { return channel_->signaling_thread_; }
rtc::Thread* signaling_thread() const { return signaling_thread_; }
rtc::Thread* network_thread() const { return channel_->network_thread_; }
DataChannelObserver* delegate_ RTC_GUARDED_BY(signaling_thread()) = nullptr;
SctpDataChannel* const channel_;
// Make sure to keep our own signaling_thread_ pointer to avoid dereferencing
// `channel_` in the `RTC_DCHECK_RUN_ON` checks on the signaling thread.
rtc::Thread* const signaling_thread_{channel_->signaling_thread_};
ScopedTaskSafety safety_;
rtc::scoped_refptr<PendingTaskSafetyFlag> signaling_safety_;
CachedGetters* cached_getters_ RTC_GUARDED_BY(signaling_thread()) = nullptr;