Loading libs/binder/RpcServer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -329,7 +329,7 @@ bool RpcServer::setupSocketServer(const RpcSocketAddress& addr) { return true; } void RpcServer::onSessionTerminating(const sp<RpcSession>& session) { void RpcServer::onSessionLockedAllServerThreadsEnded(const sp<RpcSession>& session) { auto id = session->mId; LOG_ALWAYS_FATAL_IF(id == std::nullopt, "Server sessions must be initialized with ID"); LOG_RPC_DETAIL("Dropping session %d", *id); Loading @@ -341,7 +341,7 @@ void RpcServer::onSessionTerminating(const sp<RpcSession>& session) { (void)mSessions.erase(it); } void RpcServer::onSessionThreadEnding(const sp<RpcSession>& session) { void RpcServer::onSessionServerThreadEnded(const sp<RpcSession>& session) { (void)session; mShutdownCv.notify_all(); } Loading libs/binder/RpcSession.cpp +5 −18 Original line number Diff line number Diff line Loading @@ -219,23 +219,7 @@ void RpcSession::join(unique_fd client) { } if (server != nullptr) { server->onSessionThreadEnding(sp<RpcSession>::fromExisting(this)); } } void RpcSession::terminateLocked() { // TODO(b/185167543): // - kindly notify other side of the connection of termination (can't be // locked) // - prevent new client/servers from being added // - stop all threads which are currently reading/writing // - terminate RpcState? if (mTerminated) return; sp<RpcServer> server = mForServer.promote(); if (server) { server->onSessionTerminating(sp<RpcSession>::fromExisting(this)); server->onSessionServerThreadEnded(sp<RpcSession>::fromExisting(this)); } } Loading Loading @@ -359,7 +343,10 @@ bool RpcSession::removeServerConnection(const sp<RpcConnection>& connection) { it != mServerConnections.end()) { mServerConnections.erase(it); if (mServerConnections.size() == 0) { terminateLocked(); sp<RpcServer> server = mForServer.promote(); if (server) { server->onSessionLockedAllServerThreadsEnded(sp<RpcSession>::fromExisting(this)); } } return true; } Loading libs/binder/include/binder/RpcServer.h +2 −2 Original line number Diff line number Diff line Loading @@ -153,8 +153,8 @@ public: // internal use only void onSessionTerminating(const sp<RpcSession>& session); void onSessionThreadEnding(const sp<RpcSession>& session); void onSessionLockedAllServerThreadsEnded(const sp<RpcSession>& session); void onSessionServerThreadEnded(const sp<RpcSession>& session); private: friend sp<RpcServer>; Loading libs/binder/include/binder/RpcSession.h +0 −2 Original line number Diff line number Diff line Loading @@ -144,7 +144,6 @@ private: void preJoin(std::thread thread); // join on thread passed to preJoin void join(base::unique_fd client); void terminateLocked(); struct RpcConnection : public RefBase { base::unique_fd fd; Loading Loading @@ -227,7 +226,6 @@ private: // TODO(b/185167543): allow sharing between different sessions in a // process? (or combine with mServerConnections) std::map<std::thread::id, std::thread> mThreads; bool mTerminated = false; }; } // namespace android Loading
libs/binder/RpcServer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -329,7 +329,7 @@ bool RpcServer::setupSocketServer(const RpcSocketAddress& addr) { return true; } void RpcServer::onSessionTerminating(const sp<RpcSession>& session) { void RpcServer::onSessionLockedAllServerThreadsEnded(const sp<RpcSession>& session) { auto id = session->mId; LOG_ALWAYS_FATAL_IF(id == std::nullopt, "Server sessions must be initialized with ID"); LOG_RPC_DETAIL("Dropping session %d", *id); Loading @@ -341,7 +341,7 @@ void RpcServer::onSessionTerminating(const sp<RpcSession>& session) { (void)mSessions.erase(it); } void RpcServer::onSessionThreadEnding(const sp<RpcSession>& session) { void RpcServer::onSessionServerThreadEnded(const sp<RpcSession>& session) { (void)session; mShutdownCv.notify_all(); } Loading
libs/binder/RpcSession.cpp +5 −18 Original line number Diff line number Diff line Loading @@ -219,23 +219,7 @@ void RpcSession::join(unique_fd client) { } if (server != nullptr) { server->onSessionThreadEnding(sp<RpcSession>::fromExisting(this)); } } void RpcSession::terminateLocked() { // TODO(b/185167543): // - kindly notify other side of the connection of termination (can't be // locked) // - prevent new client/servers from being added // - stop all threads which are currently reading/writing // - terminate RpcState? if (mTerminated) return; sp<RpcServer> server = mForServer.promote(); if (server) { server->onSessionTerminating(sp<RpcSession>::fromExisting(this)); server->onSessionServerThreadEnded(sp<RpcSession>::fromExisting(this)); } } Loading Loading @@ -359,7 +343,10 @@ bool RpcSession::removeServerConnection(const sp<RpcConnection>& connection) { it != mServerConnections.end()) { mServerConnections.erase(it); if (mServerConnections.size() == 0) { terminateLocked(); sp<RpcServer> server = mForServer.promote(); if (server) { server->onSessionLockedAllServerThreadsEnded(sp<RpcSession>::fromExisting(this)); } } return true; } Loading
libs/binder/include/binder/RpcServer.h +2 −2 Original line number Diff line number Diff line Loading @@ -153,8 +153,8 @@ public: // internal use only void onSessionTerminating(const sp<RpcSession>& session); void onSessionThreadEnding(const sp<RpcSession>& session); void onSessionLockedAllServerThreadsEnded(const sp<RpcSession>& session); void onSessionServerThreadEnded(const sp<RpcSession>& session); private: friend sp<RpcServer>; Loading
libs/binder/include/binder/RpcSession.h +0 −2 Original line number Diff line number Diff line Loading @@ -144,7 +144,6 @@ private: void preJoin(std::thread thread); // join on thread passed to preJoin void join(base::unique_fd client); void terminateLocked(); struct RpcConnection : public RefBase { base::unique_fd fd; Loading Loading @@ -227,7 +226,6 @@ private: // TODO(b/185167543): allow sharing between different sessions in a // process? (or combine with mServerConnections) std::map<std::thread::id, std::thread> mThreads; bool mTerminated = false; }; } // namespace android