Use pass-by-value in delayed scheduling of OnSentPacket

The change in the test failed to trigger an error on msan, but making
the change anyway out of an abundance of caution.

Bug: chromium:1496240
Change-Id: Ifa1b632f4e9ddb413f0eb23aba3f5b321b287b06
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/326080
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41083}
This commit is contained in:
Harald Alvestrand 2023-11-05 07:51:31 +00:00 committed by WebRTC LUCI CQ
parent 7fbcc8cef7
commit 99ea7c3eaa
2 changed files with 3 additions and 2 deletions

View File

@ -228,7 +228,7 @@ void RtpTransport::OnSentPacket(rtc::PacketTransportInternal* packet_transport,
packet_transport == rtcp_packet_transport_);
if (processing_sent_packet_) {
TaskQueueBase::Current()->PostTask(SafeTask(
safety_.flag(), [this, &sent_packet] { SendSentPacket(sent_packet); }));
safety_.flag(), [this, sent_packet] { SendSentPacket(sent_packet); }));
return;
}
processing_sent_packet_ = true;

View File

@ -359,14 +359,15 @@ TEST(RtpTransportTest, RecursiveOnSentPacketDoesNotCrash) {
TransportObserver observer(&transport);
const rtc::PacketOptions options;
const int flags = 0;
rtc::CopyOnWriteBuffer rtp_data(kRtpData, kRtpLen);
fake_rtp.SetWritable(true);
observer.SetActionOnSentPacket([&]() {
rtc::CopyOnWriteBuffer rtp_data(kRtpData, kRtpLen);
if (observer.sent_packet_count() < 2) {
transport.SendRtpPacket(&rtp_data, options, flags);
}
});
rtc::CopyOnWriteBuffer rtp_data(kRtpData, kRtpLen);
transport.SendRtpPacket(&rtp_data, options, flags);
EXPECT_EQ(observer.sent_packet_count(), 1);
EXPECT_EQ_WAIT(observer.sent_packet_count(), 2, kShortTimeout);