summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2022-10-10 23:12:36 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2022-10-10 23:12:36 +0000
commit560f5244a64ea1725af70bec176fc5f6eba7269c (patch)
tree42ab21438158b26280a9bc92a01b516d5b658070
parent7cde9f29b49d07707f4ee57d7d4e03961787e2ff (diff)
parent8b7a7381ceb3b6580aeee349d454a0cc5b468b05 (diff)
downloadnative-560f5244a64ea1725af70bec176fc5f6eba7269c.tar.gz
Merge "libbinder: no temp rpc sess leak w spurious wakeup"
-rw-r--r--libs/binder/RpcSession.cpp8
-rw-r--r--libs/binder/include/binder/RpcSession.h2
2 files changed, 7 insertions, 3 deletions
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp
index ff50c16102..7d6bcfc2a1 100644
--- a/libs/binder/RpcSession.cpp
+++ b/libs/binder/RpcSession.cpp
@@ -324,16 +324,18 @@ void RpcSession::WaitForShutdownListener::onSessionAllIncomingThreadsEnded(
}
void RpcSession::WaitForShutdownListener::onSessionIncomingThreadEnded() {
+ mShutdownCount += 1;
mCv.notify_all();
}
void RpcSession::WaitForShutdownListener::waitForShutdown(RpcMutexUniqueLock& lock,
const sp<RpcSession>& session) {
- while (session->mConnections.mIncoming.size() > 0) {
+ while (mShutdownCount < session->mConnections.mMaxIncoming) {
if (std::cv_status::timeout == mCv.wait_for(lock, std::chrono::seconds(1))) {
ALOGE("Waiting for RpcSession to shut down (1s w/o progress): %zu incoming connections "
- "still.",
- session->mConnections.mIncoming.size());
+ "still %zu/%zu fully shutdown.",
+ session->mConnections.mIncoming.size(), mShutdownCount.load(),
+ session->mConnections.mMaxIncoming);
}
}
}
diff --git a/libs/binder/include/binder/RpcSession.h b/libs/binder/include/binder/RpcSession.h
index 5e5d4eafa6..40faf2c3b1 100644
--- a/libs/binder/include/binder/RpcSession.h
+++ b/libs/binder/include/binder/RpcSession.h
@@ -240,6 +240,7 @@ private:
private:
RpcConditionVariable mCv;
+ std::atomic<size_t> mShutdownCount = 0;
};
friend WaitForShutdownListener;
@@ -380,6 +381,7 @@ private:
// hint index into clients, ++ when sending an async transaction
size_t mOutgoingOffset = 0;
std::vector<sp<RpcConnection>> mOutgoing;
+ // max size of mIncoming. Once any thread starts down, no more can be started.
size_t mMaxIncoming = 0;
std::vector<sp<RpcConnection>> mIncoming;
std::map<RpcMaybeThread::id, RpcMaybeThread> mThreads;