From b8f7ef1c1b244a75c58b1ff2c32e9cf8b6ac08bf Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Mon, 15 Nov 2021 08:02:27 +0000 Subject: [PATCH] Permit current queue reference to be null on sequence checker creation This makes it not an error to bind a SequenceChecker before the global TaskQueueBase::Current() is set. Unbreaks the SDP integration fuzzer. Bug: webrtc:13374 Change-Id: Ic4c23fa29f4598290cf9196550e5133ba753f44f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/237620 Reviewed-by: Niels Moller Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#35341} --- rtc_base/synchronization/sequence_checker_internal.cc | 2 +- rtc_base/unique_id_generator_unittest.cc | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/rtc_base/synchronization/sequence_checker_internal.cc b/rtc_base/synchronization/sequence_checker_internal.cc index 63badd9538..c03ee94d1b 100644 --- a/rtc_base/synchronization/sequence_checker_internal.cc +++ b/rtc_base/synchronization/sequence_checker_internal.cc @@ -51,7 +51,7 @@ bool SequenceCheckerImpl::IsCurrent() const { valid_system_queue_ = current_system_queue; return true; } - if (valid_queue_ || current_queue) { + if (valid_queue_) { return valid_queue_ == current_queue; } if (valid_system_queue_ && valid_system_queue_ == current_system_queue) { diff --git a/rtc_base/unique_id_generator_unittest.cc b/rtc_base/unique_id_generator_unittest.cc index 835a57e162..dc5e9c245f 100644 --- a/rtc_base/unique_id_generator_unittest.cc +++ b/rtc_base/unique_id_generator_unittest.cc @@ -187,6 +187,9 @@ TEST(UniqueNumberGeneratorDeathTest, FailsWhenUsedInWrongContext) { // thread/sequence checkers will pick up a different thread environment than // `fake_task_queue` will represent. UniqueNumberGenerator generator; + + // Instantiate a fake task queue that will register itself as the current tq. + FakeTaskQueue initial_fake_task_queue; // Generate an ID on the current thread. This causes the generator to attach // to the current thread context. generator.GenerateNumber();