From df741781d6f98b8012ece904e01af2eb9984adfc Mon Sep 17 00:00:00 2001 From: Alice Wang Date: Wed, 16 Nov 2022 08:37:04 +0000 Subject: [rpc_binder] Use unique_fd directly for socket in raw socket setup Test: atest binderRpcTest Bug: 222479468 Change-Id: Ie4d4cfe6ff85e91c2218eef76bd46b7b1f8d1167 --- libs/binder/RpcServer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'libs/binder/RpcServer.cpp') diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp index bd72a53805..b0dbaecca1 100644 --- a/libs/binder/RpcServer.cpp +++ b/libs/binder/RpcServer.cpp @@ -566,18 +566,17 @@ status_t RpcServer::setupSocketServer(const RpcSocketAddress& addr) { status_t RpcServer::setupRawSocketServer(base::unique_fd socket_fd) { LOG_ALWAYS_FATAL_IF(!socket_fd.ok(), "Socket must be setup to listen."); - RpcTransportFd transportFd(std::move(socket_fd)); // Right now, we create all threads at once, making accept4 slow. To avoid hanging the client, // the backlog is increased to a large number. // TODO(b/189955605): Once we create threads dynamically & lazily, the backlog can be reduced // to 1. - if (0 != TEMP_FAILURE_RETRY(listen(transportFd.fd.get(), 50 /*backlog*/))) { + if (0 != TEMP_FAILURE_RETRY(listen(socket_fd.get(), 50 /*backlog*/))) { int savedErrno = errno; ALOGE("Could not listen initialized Unix socket: %s", strerror(savedErrno)); return -savedErrno; } - if (status_t status = setupExternalServer(std::move(transportFd.fd)); status != OK) { + if (status_t status = setupExternalServer(std::move(socket_fd)); status != OK) { ALOGE("Another thread has set up server while calling setupSocketServer. Race?"); return status; } -- cgit v1.2.3-59-g8ed1b