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

Commit 5f4868aa authored by Steven Moreland's avatar Steven Moreland
Browse files

RPC Binder: handle ECONNRESET in bootstrap socket

The code here bypasses RpcState. Add logic to handle
ECONNRESET, and add a log so that we can see if this
type of issue occurs again.

Bug: 416074467
Test: binderRpcTest
Flag: EXEMPT .
Change-Id: Id5353083d47009a05ae4651e6e1f89aa9f3e78b7
parent 62df6333
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -231,10 +231,17 @@ status_t RpcServer::recvmsgSocketConnection(const RpcServer& server, RpcTranspor
    iovec iov{&zero, sizeof(zero)};
    std::vector<std::variant<unique_fd, borrowed_fd>> fds;

    // TODO: this should delegate to RpcState::rpcRec to handle transaction errors
    // consistently
    ssize_t num_bytes = binder::os::receiveMessageFromSocket(server.mServer, &iov, 1, &fds);
    if (num_bytes < 0) {
        int savedErrno = errno;
        ALOGE("Failed recvmsg: %s", strerror(savedErrno));

        if (savedErrno == ECONNRESET) {
            return DEAD_OBJECT;
        }

        return -savedErrno;
    }
    if (num_bytes == 0) {
@@ -272,11 +279,13 @@ void RpcServer::join() {

        RpcTransportFd clientSocket;
        if ((status = mAcceptFn(*this, &clientSocket)) != OK) {
            if (status == DEAD_OBJECT)
            if (status == DEAD_OBJECT) {
                break;
            else
            } else {
                ALOGE("Accept returned error %s", statusToString(status).c_str());
                continue;
            }
        }

        LOG_RPC_DETAIL("accept on fd %d yields fd %d", mServer.fd.get(), clientSocket.fd.get());