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

Commit b0468b17 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "RPC Binder: Fix TIPC disconnect error code" am: 17778063 am:...

Merge "RPC Binder: Fix TIPC disconnect error code" am: 17778063 am: 90de9e9b am: 22ebfd21 am: 45b3a5a2 am: 940b3863

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



Change-Id: I01f6e16159cc13f796897ef5623c4845f14e5258
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 55484479 940b3863
Loading
Loading
Loading
Loading
+21 −6
Original line number Original line Diff line number Diff line
@@ -54,7 +54,7 @@ public:
            }
            }


            LOG_RPC_DETAIL("RpcTransport poll(): %s", strerror(savedErrno));
            LOG_RPC_DETAIL("RpcTransport poll(): %s", strerror(savedErrno));
            return -savedErrno;
            return adjustStatus(-savedErrno);
        }
        }


        if (pfd.revents & POLLNVAL) {
        if (pfd.revents & POLLNVAL) {
@@ -87,8 +87,10 @@ public:
                                "File descriptors are not supported on Trusty yet");
                                "File descriptors are not supported on Trusty yet");
            return TEMP_FAILURE_RETRY(tipc_send(mSocket.fd.get(), iovs, niovs, nullptr, 0));
            return TEMP_FAILURE_RETRY(tipc_send(mSocket.fd.get(), iovs, niovs, nullptr, 0));
        };
        };
        return interruptableReadOrWrite(mSocket, fdTrigger, iovs, niovs, writeFn, "tipc_send",

                                        POLLOUT, altPoll);
        status_t status = interruptableReadOrWrite(mSocket, fdTrigger, iovs, niovs, writeFn,
                                                   "tipc_send", POLLOUT, altPoll);
        return adjustStatus(status);
    }
    }


    status_t interruptableReadFully(
    status_t interruptableReadFully(
@@ -121,13 +123,26 @@ public:


            return processSize;
            return processSize;
        };
        };
        return interruptableReadOrWrite(mSocket, fdTrigger, iovs, niovs, readFn, "read", POLLIN,

                                        altPoll);
        status_t status = interruptableReadOrWrite(mSocket, fdTrigger, iovs, niovs, readFn, "read",
                                                   POLLIN, altPoll);
        return adjustStatus(status);
    }
    }


    bool isWaiting() override { return mSocket.isInPollingState(); }
    bool isWaiting() override { return mSocket.isInPollingState(); }


private:
private:
    status_t adjustStatus(status_t status) {
        if (status == -ENOTCONN) {
            // TIPC returns ENOTCONN on disconnect, but that's basically
            // the same as DEAD_OBJECT and the latter is the common libbinder
            // error code for dead connections
            return DEAD_OBJECT;
        }

        return status;
    }

    status_t fillReadBuffer() {
    status_t fillReadBuffer() {
        if (mReadBufferPos < mReadBufferSize) {
        if (mReadBufferPos < mReadBufferSize) {
            return OK;
            return OK;
@@ -167,7 +182,7 @@ private:
                    continue;
                    continue;
                } else {
                } else {
                    LOG_RPC_DETAIL("RpcTransport fillBuffer(): %s", strerror(savedErrno));
                    LOG_RPC_DETAIL("RpcTransport fillBuffer(): %s", strerror(savedErrno));
                    return -savedErrno;
                    return adjustStatus(-savedErrno);
                }
                }
            } else {
            } else {
                mReadBufferSize = static_cast<size_t>(processSize);
                mReadBufferSize = static_cast<size_t>(processSize);