summaryrefslogtreecommitdiff
path: root/libs/binder/RpcServer.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2021-05-10 23:15:08 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-05-10 23:15:08 +0000
commit4fccd098967a1cad0a188672b801bf4e7b515079 (patch)
tree36f7d713d1630b5a7e4cb1df3d7b231c039d599c /libs/binder/RpcServer.cpp
parentc9fb9f924521162fd1959a99d748b6cb35acbb04 (diff)
parentb6a1e7eb34980400bdbabcab756c5a244b1f525b (diff)
Merge changes Ic0719395,Id9f1b639,I00474797,Ide06476a
* changes: libbinder: remove RpcState deadlock debug logs libbinder: RPC avoid abort on too big allocations libbinder: RPC avoid server shutdown crash libbinder: delete dead server objects
Diffstat (limited to 'libs/binder/RpcServer.cpp')
-rw-r--r--libs/binder/RpcServer.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp
index 786e2db3b3..aaebb23f6f 100644
--- a/libs/binder/RpcServer.cpp
+++ b/libs/binder/RpcServer.cpp
@@ -216,4 +216,16 @@ bool RpcServer::setupSocketServer(const RpcSocketAddress& addr) {
return true;
}
+void RpcServer::onSessionTerminating(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);
+
+ std::lock_guard<std::mutex> _l(mLock);
+ auto it = mSessions.find(*id);
+ LOG_ALWAYS_FATAL_IF(it == mSessions.end(), "Bad state, unknown session id %d", *id);
+ LOG_ALWAYS_FATAL_IF(it->second != session, "Bad state, session has id mismatch %d", *id);
+ (void)mSessions.erase(it);
+}
+
} // namespace android