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

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

Merge changes I166f3d78,I026a8bb4 am: 589958c2

parents 4c6a07a5 589958c2
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -90,16 +90,16 @@ size_t RpcSession::getMaxIncomingThreads() {
    return mMaxIncomingThreads;
}

void RpcSession::setMaxOutgoingConnections(size_t threads) {
void RpcSession::setMaxOutgoingConnections(size_t connections) {
    RpcMutexLockGuard _l(mMutex);
    LOG_ALWAYS_FATAL_IF(mStartedSetup,
                        "Must set max outgoing threads before setting up connections");
    mMaxOutgoingThreads = threads;
    mMaxOutgoingConnections = connections;
}

size_t RpcSession::getMaxOutgoingThreads() {
    RpcMutexLockGuard _l(mMutex);
    return mMaxOutgoingThreads;
    return mMaxOutgoingConnections;
}

bool RpcSession::setProtocolVersionInternal(uint32_t version, bool checkStarted) {
@@ -558,11 +558,11 @@ status_t RpcSession::setupClient(const std::function<status_t(const std::vector<
        return status;
    }

    size_t outgoingThreads = std::min(numThreadsAvailable, mMaxOutgoingThreads);
    ALOGI_IF(outgoingThreads != numThreadsAvailable,
    size_t outgoingConnections = std::min(numThreadsAvailable, mMaxOutgoingConnections);
    ALOGI_IF(outgoingConnections != numThreadsAvailable,
             "Server hints client to start %zu outgoing threads, but client will only start %zu "
             "because it is preconfigured to start at most %zu outgoing threads.",
             numThreadsAvailable, outgoingThreads, mMaxOutgoingThreads);
             numThreadsAvailable, outgoingConnections, mMaxOutgoingConnections);

    // TODO(b/189955605): we should add additional sessions dynamically
    // instead of all at once - the other side should be responsible for setting
@@ -571,10 +571,10 @@ status_t RpcSession::setupClient(const std::function<status_t(const std::vector<
    // any requests at all.

    // we've already setup one client
    LOG_RPC_DETAIL("RpcSession::setupClient() instantiating %zu outgoing (server max: %zu) and %zu "
                   "incoming threads",
                   outgoingThreads, numThreadsAvailable, mMaxIncomingThreads);
    for (size_t i = 0; i + 1 < outgoingThreads; i++) {
    LOG_RPC_DETAIL("RpcSession::setupClient() instantiating %zu outgoing connections (server max: "
                   "%zu) and %zu incoming threads",
                   outgoingConnections, numThreadsAvailable, mMaxIncomingThreads);
    for (size_t i = 0; i + 1 < outgoingConnections; i++) {
        if (status_t status = connectAndInit(mId, false /*incoming*/); status != OK) return status;
    }

+6 −6
Original line number Diff line number Diff line
@@ -54,8 +54,6 @@ constexpr uint32_t RPC_WIRE_PROTOCOL_VERSION_RPC_HEADER_FEATURE_EXPLICIT_PARCEL_
 */
class RpcSession final : public virtual RefBase {
public:
    static constexpr size_t kDefaultMaxOutgoingThreads = 10;

    // Create an RpcSession with default configuration (raw sockets).
    static sp<RpcSession> make();

@@ -80,8 +78,8 @@ public:

    /**
     * Set the maximum number of outgoing connections allowed to be made.
     * By default, this is |kDefaultMaxOutgoingThreads|. This must be called before setting up this
     * connection as a client.
     * By default, this is |kDefaultMaxOutgoingConnections|. This must be called before setting up
     * this connection as a client.
     *
     * For an RpcSession client, if you are connecting to a server which starts N threads,
     * then this must be set to >= N. If you set the maximum number of outgoing connections
@@ -90,7 +88,7 @@ public:
     * created. This API is used to limit the amount of resources a server can request you
     * create.
     */
    void setMaxOutgoingConnections(size_t threads);
    void setMaxOutgoingConnections(size_t connections);
    size_t getMaxOutgoingThreads();

    /**
@@ -223,6 +221,8 @@ private:
    friend RpcState;
    explicit RpcSession(std::unique_ptr<RpcTransportCtx> ctx);

    static constexpr size_t kDefaultMaxOutgoingConnections = 10;

    // internal version of setProtocolVersion that
    // optionally skips the mStartedSetup check
    [[nodiscard]] bool setProtocolVersionInternal(uint32_t version, bool checkStarted);
@@ -372,7 +372,7 @@ private:

    bool mStartedSetup = false;
    size_t mMaxIncomingThreads = 0;
    size_t mMaxOutgoingThreads = kDefaultMaxOutgoingThreads;
    size_t mMaxOutgoingConnections = kDefaultMaxOutgoingConnections;
    std::optional<uint32_t> mProtocolVersion;
    FileDescriptorTransportMode mFileDescriptorTransportMode = FileDescriptorTransportMode::NONE;

+1 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ void ARpcSession_setFileDescriptorTransportMode(ARpcSession* session,
void ARpcSession_setMaxIncomingThreads(ARpcSession* session, size_t threads);

// Sets the maximum number of outgoing connections.
void ARpcSession_setMaxOutgoingConnections(ARpcSession* session, size_t threads);
void ARpcSession_setMaxOutgoingConnections(ARpcSession* session, size_t connections);

// Decrements the refcount of the underlying RpcSession object.
void ARpcSession_free(ARpcSession* session);
+2 −2
Original line number Diff line number Diff line
@@ -265,8 +265,8 @@ void ARpcSession_setMaxIncomingThreads(ARpcSession* handle, size_t threads) {
    session->setMaxIncomingThreads(threads);
}

void ARpcSession_setMaxOutgoingConnections(ARpcSession* handle, size_t threads) {
void ARpcSession_setMaxOutgoingConnections(ARpcSession* handle, size_t connections) {
    auto session = handleToStrongPointer<RpcSession>(handle);
    session->setMaxOutgoingConnections(threads);
    session->setMaxOutgoingConnections(connections);
}
}