Loading libs/binder/RpcServer.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -560,4 +560,14 @@ status_t RpcServer::setupExternalServer(base::unique_fd serverFd) { return OK; } bool RpcServer::hasActiveRequests() { RpcMutexLockGuard _l(mLock); for (const auto& [_, session] : mSessions) { if (session->hasActiveRequests()) { return true; } } return !mServer.isInPollingState(); } } // namespace android libs/binder/RpcSession.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -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 libs/binder/include/binder/RpcServer.h +5 −0 Original line number Diff line number Diff line Loading @@ -187,6 +187,11 @@ public: std::vector<sp<RpcSession>> listSessions(); size_t numUninitializedSessions(); /** * Whether any requests are currently being processed. */ bool hasActiveRequests(); ~RpcServer(); private: Loading libs/binder/include/binder/RpcSession.h +10 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,11 @@ public: */ [[nodiscard]] status_t sendDecStrong(const BpBinder* binder); /** * Whether any requests are currently being processed. */ bool hasActiveRequests(); ~RpcSession(); /** Loading Loading @@ -286,6 +291,11 @@ private: [[nodiscard]] status_t initShutdownTrigger(); /** * Checks whether any connection is active (Not polling on fd) */ bool hasActiveConnection(const std::vector<sp<RpcConnection>>& connections); enum class ConnectionUse { CLIENT, CLIENT_ASYNC, Loading libs/binder/tests/rpc_fuzzer/main.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -157,8 +157,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { } } usleep(10000); if (hangupBeforeShutdown) { connections.clear(); while (!server->listSessions().empty() || server->numUninitializedSessions()) { Loading @@ -167,6 +165,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { } } while (server->hasActiveRequests()) { usleep(10); } while (!server->shutdown()) usleep(1); serverThread.join(); Loading Loading
libs/binder/RpcServer.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -560,4 +560,14 @@ status_t RpcServer::setupExternalServer(base::unique_fd serverFd) { return OK; } bool RpcServer::hasActiveRequests() { RpcMutexLockGuard _l(mLock); for (const auto& [_, session] : mSessions) { if (session->hasActiveRequests()) { return true; } } return !mServer.isInPollingState(); } } // namespace android
libs/binder/RpcSession.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -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
libs/binder/include/binder/RpcServer.h +5 −0 Original line number Diff line number Diff line Loading @@ -187,6 +187,11 @@ public: std::vector<sp<RpcSession>> listSessions(); size_t numUninitializedSessions(); /** * Whether any requests are currently being processed. */ bool hasActiveRequests(); ~RpcServer(); private: Loading
libs/binder/include/binder/RpcSession.h +10 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,11 @@ public: */ [[nodiscard]] status_t sendDecStrong(const BpBinder* binder); /** * Whether any requests are currently being processed. */ bool hasActiveRequests(); ~RpcSession(); /** Loading Loading @@ -286,6 +291,11 @@ private: [[nodiscard]] status_t initShutdownTrigger(); /** * Checks whether any connection is active (Not polling on fd) */ bool hasActiveConnection(const std::vector<sp<RpcConnection>>& connections); enum class ConnectionUse { CLIENT, CLIENT_ASYNC, Loading
libs/binder/tests/rpc_fuzzer/main.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -157,8 +157,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { } } usleep(10000); if (hangupBeforeShutdown) { connections.clear(); while (!server->listSessions().empty() || server->numUninitializedSessions()) { Loading @@ -167,6 +165,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { } } while (server->hasActiveRequests()) { usleep(10); } while (!server->shutdown()) usleep(1); serverThread.join(); Loading