diff options
author | 2022-08-26 23:23:15 +0000 | |
---|---|---|
committer | 2022-08-30 22:19:03 +0000 | |
commit | 1c24f9c97b7dffb098e57945162e74f78477d895 (patch) | |
tree | 03257185fba939511a50f6dae48b81d79f802a76 /libs/binder/RpcSession.cpp | |
parent | 11247a1bb5b02d92645ac6d94f3aaa34476fd0c7 (diff) |
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
Diffstat (limited to 'libs/binder/RpcSession.cpp')
-rw-r--r-- | libs/binder/RpcSession.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
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<sp<RpcConnection>>& 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 |