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}
diff --git a/rtc_base/task_utils/repeating_task_unittest.cc b/rtc_base/task_utils/repeating_task_unittest.cc
index 79bce06..52683e3 100644
--- a/rtc_base/task_utils/repeating_task_unittest.cc
+++ b/rtc_base/task_utils/repeating_task_unittest.cc
@@ -112,13 +112,14 @@
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);
}