Merge "[rpc_binder] Adjust return when raw socket is not set up" am: 97970145ac
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2303058
Change-Id: I28af92b5192694af41c432b0b4363e455db222fa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp
index 399667d..bd72a53 100644
--- a/libs/binder/RpcServer.cpp
+++ b/libs/binder/RpcServer.cpp
@@ -565,12 +565,9 @@
}
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));
- if (!transportFd.fd.ok()) {
- int savedErrno = errno;
- ALOGE("Could not get initialized Unix socket: %s", strerror(savedErrno));
- return -savedErrno;
- }
+
// 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
diff --git a/libs/binder/libbinder_rpc_unstable.cpp b/libs/binder/libbinder_rpc_unstable.cpp
index ae07aee..9edb3b6 100644
--- a/libs/binder/libbinder_rpc_unstable.cpp
+++ b/libs/binder/libbinder_rpc_unstable.cpp
@@ -94,6 +94,10 @@
void (*readyCallback)(void* param), void* param) {
auto server = RpcServer::make();
auto fd = unique_fd(android_get_control_socket(name));
+ if (!fd.ok()) {
+ LOG(ERROR) << "Failed to get fd for the socket:" << name;
+ return false;
+ }
if (status_t status = server->setupRawSocketServer(std::move(fd)); status != OK) {
LOG(ERROR) << "Failed to set up Unix Domain RPC server with name " << name
<< " error: " << statusToString(status).c_str();