From 499de2d395c4bd3b7d4ef193289373f0ea8c5c9f Mon Sep 17 00:00:00 2001 From: Yves Gerey Date: Fri, 3 Jan 2020 17:12:49 +0100 Subject: [PATCH] Fix tiny race condition when Vp9NonFlexMode_* tests were failing. TSAN complained at each failure, which only added confusion. Bug: webrtc:11243 Change-Id: Ic36ec13562699478be23050a7b723e1b9bb47f0e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/164528 Reviewed-by: Henrik Andreassson Commit-Queue: Yves Gerey Cr-Commit-Position: refs/heads/master@{#30161} --- video/video_send_stream_tests.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc index f49a7633db..41473f19cb 100644 --- a/video/video_send_stream_tests.cc +++ b/video/video_send_stream_tests.cc @@ -3149,8 +3149,13 @@ class Vp9HeaderObserver : public test::SendTest { } void PerformTest() override { - EXPECT_TRUE(Wait()) << "Test timed out waiting for VP9 packet, num frames " + bool wait = Wait(); + { + // In case of time out, OnSendRtp might still access frames_sent_; + rtc::CritScope lock(&crit_); + EXPECT_TRUE(wait) << "Test timed out waiting for VP9 packet, num frames " << frames_sent_; + } } Action OnSendRtp(const uint8_t* packet, size_t length) override { @@ -3179,6 +3184,7 @@ class Vp9HeaderObserver : public test::SendTest { ++packets_sent_; if (rtp_packet.Marker()) { + rtc::CritScope lock(&crit_); ++frames_sent_; } last_packet_marker_ = rtp_packet.Marker(); @@ -3405,6 +3411,7 @@ class Vp9HeaderObserver : public test::SendTest { uint32_t last_packet_timestamp_ = 0; RTPVideoHeaderVP9 last_vp9_; size_t packets_sent_; + rtc::CriticalSection crit_; size_t frames_sent_; int expected_width_; int expected_height_;