From 5f2bc56da8edbcc328b213f783d5b494ae0fa26e Mon Sep 17 00:00:00 2001 From: Andrei Homescu Date: Sat, 25 Feb 2023 04:59:43 +0000 Subject: libbinder: Flush pending messages in OnewayCallQueuingWithFds The OnewayCallQueuingWithFds test uses oneway calls and needs to handle the incoming decrefs sent by flushExcessBinderRefs on the other side. This change flushes those decref messages using saturateThreadPool which makes one sync call on every server thread, forcing the session to read and handle all those pending messages. Bug: 259517277 Test: presubmit Change-Id: Ib4a9b637baa763f3f0a9429e5c494ce86352a9c6 --- libs/binder/tests/binderRpcTest.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libs/binder') diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp index 84c93ddc30..dcea880ef9 100644 --- a/libs/binder/tests/binderRpcTest.cpp +++ b/libs/binder/tests/binderRpcTest.cpp @@ -544,6 +544,8 @@ TEST_P(BinderRpc, OnewayCallQueueingWithFds) { GTEST_SKIP() << "This test requires multiple threads"; } + constexpr size_t kNumServerThreads = 3; + // This test forces a oneway transaction to be queued by issuing two // `blockingSendFdOneway` calls, then drains the queue by issuing two // `blockingRecvFd` calls. @@ -552,7 +554,7 @@ TEST_P(BinderRpc, OnewayCallQueueingWithFds) { // https://developer.android.com/reference/android/os/IBinder#FLAG_ONEWAY auto proc = createRpcTestSocketServerProcess({ - .numThreads = 3, + .numThreads = kNumServerThreads, .clientFileDescriptorTransportMode = RpcSession::FileDescriptorTransportMode::UNIX, .serverSupportedFileDescriptorTransportModes = {RpcSession::FileDescriptorTransportMode::UNIX}, @@ -573,6 +575,8 @@ TEST_P(BinderRpc, OnewayCallQueueingWithFds) { EXPECT_OK(proc.rootIface->blockingRecvFd(&fdB)); CHECK(android::base::ReadFdToString(fdB.get(), &result)); EXPECT_EQ(result, "b"); + + saturateThreadPool(kNumServerThreads, proc.rootIface); } TEST_P(BinderRpc, OnewayCallQueueing) { -- cgit v1.2.3-59-g8ed1b