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

Commit 89ff119c authored by Kevin Jeon's avatar Kevin Jeon
Browse files

Change behavior around removing mLooperProcessed

When removing a message that is also mLooperProcessed, we should set
mLooperProcessed to mLooperProcessed.next instead of running through the
stack for a non-removed message. This is because we may accidentally add
these skipped removed messages to the heap if the thread that marked
them for removal hasn't pushed them onto the freelist yet.

Test: presubmit (FrameworksCoreTests_messagequeue)
Bug: 444085764
Flag: build.RELEASE_PACKAGE_MESSAGEQUEUE_IMPLEMENTATION
Change-Id: I83536c0ef383f4984a3be84ce9c9a129ea39b275
parent 5a203808
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -281,11 +281,9 @@ public final class MessageStack {
     * Remove a message from the stack.
     */
    private void removeFromStack(Message m) {
        // mLooperProcessed must be updated to the next message that hasn't been removed.
        // mLooperProcessed must be updated to the next message.
        if (m == mLooperProcessed) {
            do {
            mLooperProcessed = mLooperProcessed.next;
            } while (mLooperProcessed != null && mLooperProcessed.isRemoved());
        }

        // If prev is null, m was the top at the time the previous heapSweep was called.