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

Commit 560f5244 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "libbinder: no temp rpc sess leak w spurious wakeup"

parents 7cde9f29 8b7a7381
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -324,16 +324,18 @@ void RpcSession::WaitForShutdownListener::onSessionAllIncomingThreadsEnded(
}

void RpcSession::WaitForShutdownListener::onSessionIncomingThreadEnded() {
    mShutdownCount += 1;
    mCv.notify_all();
}

void RpcSession::WaitForShutdownListener::waitForShutdown(RpcMutexUniqueLock& lock,
                                                          const sp<RpcSession>& session) {
    while (session->mConnections.mIncoming.size() > 0) {
    while (mShutdownCount < session->mConnections.mMaxIncoming) {
        if (std::cv_status::timeout == mCv.wait_for(lock, std::chrono::seconds(1))) {
            ALOGE("Waiting for RpcSession to shut down (1s w/o progress): %zu incoming connections "
                  "still.",
                  session->mConnections.mIncoming.size());
                  "still %zu/%zu fully shutdown.",
                  session->mConnections.mIncoming.size(), mShutdownCount.load(),
                  session->mConnections.mMaxIncoming);
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -240,6 +240,7 @@ private:

    private:
        RpcConditionVariable mCv;
        std::atomic<size_t> mShutdownCount = 0;
    };
    friend WaitForShutdownListener;

@@ -380,6 +381,7 @@ private:
        // hint index into clients, ++ when sending an async transaction
        size_t mOutgoingOffset = 0;
        std::vector<sp<RpcConnection>> mOutgoing;
        // max size of mIncoming. Once any thread starts down, no more can be started.
        size_t mMaxIncoming = 0;
        std::vector<sp<RpcConnection>> mIncoming;
        std::map<RpcMaybeThread::id, RpcMaybeThread> mThreads;