From 43921d5d92d6e27bf1ec00de062746f032268717 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Mon, 27 Sep 2021 17:15:56 -0700 Subject: libbinder: RPC handle builtup refcounts Generally, in the binder RPC wire protocol, we don't have both the clients and the servers writing data into sockets. However, in the case of async transactions, this happens in an unbounded way because a client may send many oneway transactions, and the server will be sending back refcounting information related to these transactions (which we process lazily). In order to prevent this from building up, when sending a transaction, if we're unable to write it, instead of waiting, drain that reference counting information. Bug: 182940634 Test: binderRpcTest (no longer deadlocks in OnewayStressTest) Test: manually check 'drainCommands' happens in both raw and tls cases during this test (checking we are actually getting coverage) Change-Id: I82039d6188196261b22316e95d8e180c4c33ae73 --- libs/binder/RpcServer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libs/binder/RpcServer.cpp') diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp index 5733993b3b..cf95fda8ce 100644 --- a/libs/binder/RpcServer.cpp +++ b/libs/binder/RpcServer.cpp @@ -275,7 +275,7 @@ void RpcServer::establishConnection(sp&& server, base::unique_fd clie RpcConnectionHeader header; if (status == OK) { status = client->interruptableReadFully(server->mShutdownTrigger.get(), &header, - sizeof(header)); + sizeof(header), {}); if (status != OK) { ALOGE("Failed to read ID for client connecting to RPC server: %s", statusToString(status).c_str()); @@ -288,7 +288,7 @@ void RpcServer::establishConnection(sp&& server, base::unique_fd clie if (header.sessionIdSize > 0) { sessionId.resize(header.sessionIdSize); status = client->interruptableReadFully(server->mShutdownTrigger.get(), - sessionId.data(), sessionId.size()); + sessionId.data(), sessionId.size(), {}); if (status != OK) { ALOGE("Failed to read session ID for client connecting to RPC server: %s", statusToString(status).c_str()); @@ -313,7 +313,7 @@ void RpcServer::establishConnection(sp&& server, base::unique_fd clie }; status = client->interruptableWriteFully(server->mShutdownTrigger.get(), &response, - sizeof(response)); + sizeof(response), {}); if (status != OK) { ALOGE("Failed to send new session response: %s", statusToString(status).c_str()); // still need to cleanup before we can return -- cgit v1.2.3-59-g8ed1b