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

Commit f4c81378 authored by Frankie Chang's avatar Frankie Chang Committed by Steven Moreland
Browse files

ANDROID: binder: prevent double flushing when free buffer

Change-Id: I959ea32145a530f49288cc84b5ce27808937ff2e
Bug: 188512748
parent 33fd596d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -516,14 +516,16 @@ void IPCThreadState::flushCommands()

bool IPCThreadState::flushIfNeeded()
{
    if (mIsLooper || mServingStackPointer != nullptr) {
    if (mIsLooper || mServingStackPointer != nullptr || mIsFlushing) {
        return false;
    }
    mIsFlushing = true;
    // 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
    // soon. Therefore, flush pending commands such as BC_FREE_BUFFER, to prevent them from getting
    // stuck in this thread's out buffer.
    flushCommands();
    mIsFlushing = false;
    return true;
}

@@ -880,6 +882,7 @@ IPCThreadState::IPCThreadState()
        mWorkSource(kUnsetWorkSource),
        mPropagateWorkSource(false),
        mIsLooper(false),
        mIsFlushing(false),
        mStrictModePolicy(0),
        mLastTransactionBinderFlags(0),
        mCallRestriction(mProcess->mCallRestriction) {
+1 −0
Original line number Diff line number Diff line
@@ -243,6 +243,7 @@ private:
            // Whether the work source should be propagated.
            bool                mPropagateWorkSource;
            bool                mIsLooper;
            bool mIsFlushing;
            int32_t             mStrictModePolicy;
            int32_t             mLastTransactionBinderFlags;
            CallRestriction     mCallRestriction;