Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: webrtc/base/task_queue_unittest.cc

Issue 2709603002: Fix potential deadlock in TaskQueue's libevent PostTaskAndReply implementation (Closed)
Patch Set: Update comment Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« webrtc/base/task_queue_libevent.cc ('K') | « webrtc/base/task_queue_libevent.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/task_queue_unittest.cc
diff --git a/webrtc/base/task_queue_unittest.cc b/webrtc/base/task_queue_unittest.cc
index 74433b91440117250fc72cc959326db0afa2f935..a263610acafbc1e226b10df4c73aadb18a97305c 100644
--- a/webrtc/base/task_queue_unittest.cc
+++ b/webrtc/base/task_queue_unittest.cc
@@ -206,6 +206,24 @@ TEST(TaskQueueTest, PostAndReplyLambda) {
EXPECT_TRUE(my_flag);
}
+// This test covers a particular bug that we had in the libevent implementation
+// where we could hit a deadlock while trying to post a reply task to a queue
+// that was being deleted. The test isn't guaranteed to hit that case but it's
+// written in a way that makes it likely and by running with --gtest_repeat=1000
+// the bug would occur. Alas, now it should be fixed.
+TEST(TaskQueueTest, PostAndReplyDeadlock) {
+ static const char kPostQueue[] = "PostQueue";
Taylor Brandstetter 2017/02/22 00:24:27 Out of curiosity, what's the purpose of having "st
tommi 2017/02/22 12:43:54 When I started writing these tests, the constant v
+ static const char kReplyQueue[] = "ReplyQueue";
+ std::unique_ptr<TaskQueue> post_queue(new TaskQueue(kPostQueue));
Taylor Brandstetter 2017/02/22 00:24:28 These don't need to be unique_ptrs
tommi 2017/02/22 12:43:54 Done. I made them unique_ptrs while debugging so
+ std::unique_ptr<TaskQueue> reply_queue(new TaskQueue(kReplyQueue));
+
+ Event event(false, false);
+ post_queue->PostTaskAndReply([&event]() { event.Set(); }, []() {},
+ reply_queue.get());
+ EXPECT_TRUE(event.Wait(1000));
+ reply_queue.reset();
+}
+
void TestPostTaskAndReply(TaskQueue* work_queue,
const char* work_queue_name,
Event* event) {
« webrtc/base/task_queue_libevent.cc ('K') | « webrtc/base/task_queue_libevent.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698