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

Commit 35a88e97 authored by Steven Moreland's avatar Steven Moreland
Browse files

RPC Binder: bootstrap clients non-blocking

Without this, if they are in the middle of receiving a call, they may
hang indefinitely. This fixes that deadlock.

I repro'd this by modifying polling to periodically return.

Future considerations - RpcTransport should verify or set this
itself, rather than risking new codepaths don't set this.

Bug: 416772676
Bug: 419364025
Test: binderRpcTest

Change-Id: Idfebc231ba0c2d8c8d54672116a1b9dc8e6dc86c
parent 8443b19b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -657,6 +657,8 @@ unique_fd RpcServer::releaseServer() {

status_t RpcServer::setupExternalServer(
        unique_fd serverFd, std::function<status_t(const RpcServer&, RpcTransportFd*)>&& acceptFn) {
    if (status_t res = binder::os::setNonBlocking(serverFd); res != OK) return res;

    RpcMutexLockGuard _l(mLock);
    if (mServer.fd.ok()) {
        ALOGE("Each RpcServer can only have one server.");
+2 −0
Original line number Diff line number Diff line
@@ -142,6 +142,8 @@ status_t RpcSession::setupUnixDomainClient(const char* path) {
}

status_t RpcSession::setupUnixDomainSocketBootstrapClient(unique_fd bootstrapFd) {
    if (status_t res = binder::os::setNonBlocking(bootstrapFd); res != OK) return res;

    mBootstrapTransport =
            mCtx->newTransport(RpcTransportFd(std::move(bootstrapFd)), mShutdownTrigger.get());
    return setupClient([&](const std::vector<uint8_t>& sessionId, bool incoming) {