Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30c204d3 authored by Alice Wang's avatar Alice Wang
Browse files

[rpc_binder] Adjust return when raw socket is not set up

This cl adjusts the return in RpcServer::setupRawSocketServer()
when the socket_fd is not set up. Prior to this cl, errno is
returned. This can be confusing as errno is not always set up in
this case. The current CL fixed this and logged more clear
information.

Test: atest binderRpcTest
Bug: 222479468
Change-Id: Ic9718cbf3cf08befe4044e7f5f021b915b4c4c41
parent a8c0dd74
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -565,12 +565,9 @@ 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));
    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
+4 −0
Original line number Diff line number Diff line
@@ -94,6 +94,10 @@ bool RunInitUnixDomainRpcServer(AIBinder* service, const char* name,
                                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();