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

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

Merge "ANDROID: binder: prevent double flushing when free buffer" into sc-dev am: 2870c451

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

Change-Id: Ifb1b0001b1505e870452679f2ba54cdcad3f17b7
parents 1cec3edd 2870c451
Loading
Loading
Loading
Loading
+12 −10
Original line number Original line Diff line number Diff line
@@ -489,14 +489,16 @@ void IPCThreadState::flushCommands()


bool IPCThreadState::flushIfNeeded()
bool IPCThreadState::flushIfNeeded()
{
{
    if (mIsLooper || mServingStackPointer != nullptr) {
    if (mIsLooper || mServingStackPointer != nullptr || mIsFlushing) {
        return false;
        return false;
    }
    }
    mIsFlushing = true;
    // In case this thread is not a looper and is not currently serving a binder transaction,
    // In case this thread is not a looper and is not currently serving a binder transaction,
    // there's no guarantee that this thread will call back into the kernel driver any time
    // there's no guarantee that this thread will call back into the kernel driver any time
    // soon. Therefore, flush pending commands such as BC_FREE_BUFFER, to prevent them from getting
    // soon. Therefore, flush pending commands such as BC_FREE_BUFFER, to prevent them from getting
    // stuck in this thread's out buffer.
    // stuck in this thread's out buffer.
    flushCommands();
    flushCommands();
    mIsFlushing = false;
    return true;
    return true;
}
}


@@ -852,10 +854,10 @@ IPCThreadState::IPCThreadState()
        mWorkSource(kUnsetWorkSource),
        mWorkSource(kUnsetWorkSource),
        mPropagateWorkSource(false),
        mPropagateWorkSource(false),
        mIsLooper(false),
        mIsLooper(false),
        mIsFlushing(false),
        mStrictModePolicy(0),
        mStrictModePolicy(0),
        mLastTransactionBinderFlags(0),
        mLastTransactionBinderFlags(0),
      mCallRestriction(mProcess->mCallRestriction)
        mCallRestriction(mProcess->mCallRestriction) {
{
    pthread_setspecific(gTLS, this);
    pthread_setspecific(gTLS, this);
    clearCaller();
    clearCaller();
    mIn.setDataCapacity(256);
    mIn.setDataCapacity(256);
+1 −0
Original line number Original line Diff line number Diff line
@@ -212,6 +212,7 @@ private:
            // Whether the work source should be propagated.
            // Whether the work source should be propagated.
            bool                mPropagateWorkSource;
            bool                mPropagateWorkSource;
            bool                mIsLooper;
            bool                mIsLooper;
            bool mIsFlushing;
            int32_t             mStrictModePolicy;
            int32_t             mStrictModePolicy;
            int32_t             mLastTransactionBinderFlags;
            int32_t             mLastTransactionBinderFlags;
            CallRestriction     mCallRestriction;
            CallRestriction     mCallRestriction;