From 1c24f9c97b7dffb098e57945162e74f78477d895 Mon Sep 17 00:00:00 2001 From: Pawan Date: Fri, 26 Aug 2022 23:23:15 +0000 Subject: libbinder : Avoid waiting in binder_rpc_fuzzer Introducing new APIs in RpcServer and RpcSession to check polling state of file descriptor. Removing fixed wait time in binder_rpc_fuzzer. Test: m binder_rpc_fuzzer && $ANDROID_HOST_OUT/fuzz/x86_64/binder_rpc_fuzzer/binder_rpc_fuzzer Bug: 218518615 Change-Id: Ied82cd9c16514761a489731488924274a17053a6 --- libs/binder/RpcSession.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libs/binder/RpcSession.cpp') diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp index bef2ed63c7..49843e5953 100644 --- a/libs/binder/RpcSession.cpp +++ b/libs/binder/RpcSession.cpp @@ -952,4 +952,24 @@ RpcSession::ExclusiveConnection::~ExclusiveConnection() { } } +bool RpcSession::hasActiveConnection(const std::vector>& connections) { + for (const auto& connection : connections) { + if (connection->exclusiveTid != std::nullopt && !connection->rpcTransport->isWaiting()) { + return true; + } + } + return false; +} + +bool RpcSession::hasActiveRequests() { + RpcMutexUniqueLock _l(mMutex); + if (hasActiveConnection(mConnections.mIncoming)) { + return true; + } + if (hasActiveConnection(mConnections.mOutgoing)) { + return true; + } + return mConnections.mWaitingThreads != 0; +} + } // namespace android -- cgit v1.2.3-59-g8ed1b