diff options
author | 2021-05-25 02:25:07 +0000 | |
---|---|---|
committer | 2021-05-25 02:25:07 +0000 | |
commit | 45916263e09d63771c7cc9748f134b45de563c05 (patch) | |
tree | 32c95fb6ad485a1b7edfc686b43f579fe8a90c25 /libs/binder/RpcServer.cpp | |
parent | eaa613b4b3cded9a8ed11c02b7fcf66770a5b397 (diff) | |
parent | 6c6cd10c01a613f20a00a8e8394b5977c9e0ff33 (diff) |
Merge "libbinder: shutdown session threads" am: c1500480cb am: e8990d0d2a am: bf6d2a9c43 am: 6c6cd10c01
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1716214
Change-Id: I02b7a1f5cf7fef32a5c88983f63b83dfc0497306
Diffstat (limited to 'libs/binder/RpcServer.cpp')
-rw-r--r-- | libs/binder/RpcServer.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp index e3bf2a5e36..bff5543c9b 100644 --- a/libs/binder/RpcServer.cpp +++ b/libs/binder/RpcServer.cpp @@ -192,10 +192,10 @@ bool RpcServer::shutdown() { } mShutdownTrigger->trigger(); - while (mJoinThreadRunning || !mConnectingThreads.empty()) { + while (mJoinThreadRunning || !mConnectingThreads.empty() || !mSessions.empty()) { ALOGI("Waiting for RpcServer to shut down. Join thread running: %d, Connecting threads: " - "%zu", - mJoinThreadRunning, mConnectingThreads.size()); + "%zu, Sessions: %zu", + mJoinThreadRunning, mConnectingThreads.size(), mSessions.size()); mShutdownCv.wait(_l); } @@ -278,7 +278,8 @@ void RpcServer::establishConnection(sp<RpcServer>&& server, base::unique_fd clie server->mSessionIdCounter++; session = RpcSession::make(); - session->setForServer(wp<RpcServer>(server), server->mSessionIdCounter); + session->setForServer(wp<RpcServer>(server), server->mSessionIdCounter, + server->mShutdownTrigger); server->mSessions[server->mSessionIdCounter] = session; } else { @@ -344,6 +345,11 @@ void RpcServer::onSessionTerminating(const sp<RpcSession>& session) { (void)mSessions.erase(it); } +void RpcServer::onSessionThreadEnding(const sp<RpcSession>& session) { + (void)session; + mShutdownCv.notify_all(); +} + bool RpcServer::hasServer() { LOG_ALWAYS_FATAL_IF(!mAgreedExperimental, "no!"); std::lock_guard<std::mutex> _l(mLock); |