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

Commit 90404f51 authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "RPC Binder: setMaxOutgoing{Threads,Connections}" am: f297a61c am:...

Merge "RPC Binder: setMaxOutgoing{Threads,Connections}" am: f297a61c am: 6693a493 am: 3ee7fe97 am: 81456f15

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



Change-Id: I1d699522ca4175538ae6e053a11290b5bbb356ee
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 41de3cd4 81456f15
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ int main(int argc, char* const argv[])
    ProcessState::initWithDriver("/dev/vndbinder");
#endif
#ifndef __ANDROID__
    setDefaultServiceManager(createRpcDelegateServiceManager({.maxOutgoingThreads = 1}));
    setDefaultServiceManager(createRpcDelegateServiceManager({.maxOutgoingConnections = 1}));
#endif
    sp<IServiceManager> sm = defaultServiceManager();
    fflush(stdout);
+3 −2
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ size_t RpcSession::getMaxIncomingThreads() {
    return mMaxIncomingThreads;
}

void RpcSession::setMaxOutgoingThreads(size_t threads) {
void RpcSession::setMaxOutgoingConnections(size_t threads) {
    RpcMutexLockGuard _l(mMutex);
    LOG_ALWAYS_FATAL_IF(mStartedSetup,
                        "Must set max outgoing threads before setting up connections");
@@ -932,7 +932,8 @@ status_t RpcSession::ExclusiveConnection::find(const sp<RpcSession>& session, Co
                  (session->server()
                           ? "This is a server session, so see RpcSession::setMaxIncomingThreads "
                             "for the corresponding client"
                           : "This is a client session, so see RpcSession::setMaxOutgoingThreads "
                           : "This is a client session, so see "
                             "RpcSession::setMaxOutgoingConnections "
                             "for this client or RpcServer::setMaxThreads for the corresponding "
                             "server"));
            return WOULD_BLOCK;
+2 −2
Original line number Diff line number Diff line
@@ -159,8 +159,8 @@ sp<IBinder> getDeviceService(std::vector<std::string>&& serviceDispatcherArgs,
    LOG_ALWAYS_FATAL_IF(!forwardResult->hostPort().has_value());

    auto rpcSession = RpcSession::make();
    if (options.maxOutgoingThreads.has_value()) {
        rpcSession->setMaxOutgoingThreads(*options.maxOutgoingThreads);
    if (options.maxOutgoingConnections.has_value()) {
        rpcSession->setMaxOutgoingConnections(*options.maxOutgoingConnections);
    }

    if (status_t status = rpcSession->setupInetClient("127.0.0.1", *forwardResult->hostPort());
+5 −5
Original line number Diff line number Diff line
@@ -224,12 +224,12 @@ bool checkPermission(const String16& permission, pid_t pid, uid_t uid,
//    }
// Resources are cleaned up when the object is destroyed.
//
// For each returned binder object, at most |maxOutgoingThreads| outgoing threads are instantiated.
// Hence, only |maxOutgoingThreads| calls can be made simultaneously. Additional calls are blocked
// if there are |maxOutgoingThreads| ongoing calls. See RpcSession::setMaxOutgoingThreads.
// If |maxOutgoingThreads| is not set, default is |RpcSession::kDefaultMaxOutgoingThreads|.
// For each returned binder object, at most |maxOutgoingConnections| outgoing connections are
// instantiated, depending on how many the service on the device is configured with.
// Hence, only |maxOutgoingConnections| calls can be made simultaneously.
// See also RpcSession::setMaxOutgoingConnections.
struct RpcDelegateServiceManagerOptions {
    std::optional<size_t> maxOutgoingThreads;
    std::optional<size_t> maxOutgoingConnections;
};
sp<IServiceManager> createRpcDelegateServiceManager(
        const RpcDelegateServiceManagerOptions& options);
+4 −1
Original line number Diff line number Diff line
@@ -119,7 +119,10 @@ public:
    [[nodiscard]] status_t setupExternalServer(base::unique_fd serverFd);

    /**
     * This must be called before adding a client session.
     * This must be called before adding a client session. This corresponds
     * to the number of incoming connections to RpcSession objects in the
     * server, which will correspond to the number of outgoing connections
     * in client RpcSession objects.
     *
     * If this is not specified, this will be a single-threaded server.
     *
Loading