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) { |