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

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

Merge "libbinder: log when threads requested, not started" into main am: 38a4ab9f am: c0d95276

parents 02efc704 c0d95276
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -775,6 +775,7 @@ void IPCThreadState::joinThreadPool(bool isMain)
{
    LOG_THREADPOOL("**** THREAD %p (PID %d) IS JOINING THE THREAD POOL\n", (void*)pthread_self(),
                   getpid());
    mProcess->checkExpectingThreadPoolStart();
    mProcess->mCurrentThreads++;
    mOut.writeInt32(isMain ? BC_ENTER_LOOPER : BC_REGISTER_LOOPER);

+15 −0
Original line number Diff line number Diff line
@@ -501,6 +501,21 @@ bool ProcessState::isThreadPoolStarted() const {
    return mThreadPoolStarted;
}

void ProcessState::checkExpectingThreadPoolStart() const {
    if (mThreadPoolStarted) return;

    // this is also racey, but you should setup the threadpool in the main thread. If that is an
    // issue, we can check if we are the process leader, but haven't seen the issue in practice.
    size_t requestedThreads = mMaxThreads.load();

    // if it's manually set to the default, we do ignore it here...
    if (requestedThreads == DEFAULT_MAX_BINDER_THREADS) return;
    if (requestedThreads == 0) return;

    ALOGW("Thread pool configuration of size %zu requested, but startThreadPool was not called.",
          requestedThreads);
}

#define DRIVER_FEATURES_PATH "/dev/binderfs/features/"
bool ProcessState::isDriverFeatureEnabled(const DriverFeature feature) {
    // Use static variable to cache the results.
+2 −0
Original line number Diff line number Diff line
@@ -141,6 +141,8 @@ public:
private:
    static sp<ProcessState> init(const char* defaultDriver, bool requireDefault);

    void checkExpectingThreadPoolStart() const;

    static void onFork();
    static void parentPostFork();
    static void childPostFork();