Avoids PostTask to repost a repeated task.
There seems to be a race caused by the libevent wrapping TaskQueue implementation when reposting a repeated task at destruction time. This race results in the posted task being leaked according to asan. Bug: webrtc:10278 Change-Id: Ida40b884547f3f789a804ca0ab3ce36982a4d68e Reviewed-on: https://webrtc-review.googlesource.com/c/121424 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26839}
This commit is contained in:
committed by
Commit Bot
parent
ce7a4fb67b
commit
a497d12a02
@ -112,13 +112,14 @@ TEST(RepeatingTaskTest, CompensatesForShortRunTime) {
|
||||
rtc::TaskQueue task_queue("TestQueue");
|
||||
RepeatingTaskHandle::Start(&task_queue, [&] {
|
||||
++counter;
|
||||
// Sleeping for the 5 ms should be compensated.
|
||||
Sleep(TimeDelta::ms(5));
|
||||
return TimeDelta::ms(10);
|
||||
// Sleeping for the 10 ms should be compensated.
|
||||
Sleep(TimeDelta::ms(10));
|
||||
return TimeDelta::ms(30);
|
||||
});
|
||||
Sleep(TimeDelta::ms(15));
|
||||
Sleep(TimeDelta::ms(40));
|
||||
|
||||
// We expect that the task have been called twice, once directly at Start and
|
||||
// once after 10 ms has passed.
|
||||
// once after 30 ms has passed.
|
||||
EXPECT_EQ(counter.load(), 2);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user