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

Commit 5bd715c2 authored by Alice Wang's avatar Alice Wang Committed by Automerger Merge Worker
Browse files

Merge "[rpc_binder] Use unique_fd directly for socket in raw socket setup" am:...

Merge "[rpc_binder] Use unique_fd directly for socket in raw socket setup" am: 8353dd26 am: 5144d416

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2303772



Change-Id: I4e09db8f96219fc2ce0d10139177074dec516e51
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 283f3b75 5144d416
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -549,18 +549,17 @@ status_t RpcServer::setupSocketServer(const RpcSocketAddress& addr) {

status_t RpcServer::setupRawSocketServer(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;
    }