From 1803bb247055669e9da4a082077078960de62a7f Mon Sep 17 00:00:00 2001 From: Christoffer Rodbro Date: Thu, 25 Oct 2018 12:39:49 +0200 Subject: [PATCH] Fix for clock read race in FakeNetworkPipe. Bug: none Change-Id: Id708c532bfc0c9cd696a974d455ff79f25c222fe Reviewed-on: https://webrtc-review.googlesource.com/c/107880 Reviewed-by: Sebastian Jansson Commit-Queue: Christoffer Rodbro Cr-Commit-Position: refs/heads/master@{#25363} --- call/fake_network_pipe.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/call/fake_network_pipe.cc b/call/fake_network_pipe.cc index df97046ad6..7222dfd0ab 100644 --- a/call/fake_network_pipe.cc +++ b/call/fake_network_pipe.cc @@ -154,8 +154,8 @@ bool FakeNetworkPipe::EnqueuePacket(rtc::CopyOnWriteBuffer packet, bool is_rtcp, MediaType media_type, absl::optional packet_time_us) { - int64_t time_now_us = clock_->TimeInMicroseconds(); rtc::CritScope crit(&process_lock_); + int64_t time_now_us = clock_->TimeInMicroseconds(); size_t packet_size = packet.size(); NetworkPacket net_packet(std::move(packet), time_now_us, time_now_us, options, is_rtcp, media_type, packet_time_us); @@ -201,10 +201,11 @@ size_t FakeNetworkPipe::SentPackets() { } void FakeNetworkPipe::Process() { - int64_t time_now_us = clock_->TimeInMicroseconds(); + int64_t time_now_us; std::queue packets_to_deliver; { rtc::CritScope crit(&process_lock_); + time_now_us = clock_->TimeInMicroseconds(); if (time_now_us - last_log_time_us_ > kLogIntervalMs * 1000) { int64_t queueing_delay_us = 0; if (!packets_in_flight_.empty())