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

Commit 10bc73e6 authored by Shai Barack's avatar Shai Barack
Browse files

Check, reset, and restore interrupted state correctly while looping around park()

Fixes: 409869563
Test: N/A can't reliably reproduce the issue and observe the undesired spin behavior
Flag: build.RELEASE_PACKAGE_MESSAGEQUEUE_IMPLEMENTATION
Change-Id: I5ba622b54d4fd7f09bf0c2c15f68a9c153cc9a1a
parent c14deabd
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -2701,8 +2701,16 @@ public final class MessageQueue {
            return false;
        }
        mLooperThread = Thread.currentThread();
        boolean wasInterrupted = false;
        try {
            while ((mQuittingRefCountValue & ~QUITTING_MASK) != 0) {
                LockSupport.park();
                wasInterrupted |= Thread.interrupted();
            }
        } finally {
            if (wasInterrupted) {
                mLooperThread.interrupt();
            }
        }
        return true;
    }
+10 −3
Original line number Diff line number Diff line
@@ -280,9 +280,16 @@ public final class MessageQueue {
        if (!getQuitting()) {
            return false;
        }
        mLooperThread = Thread.currentThread();
        boolean wasInterrupted = false;
        try {
            while ((mQuittingRefCountValue & ~QUITTING_MASK) != 0) {
                LockSupport.park();
                wasInterrupted |= Thread.interrupted();
            }
        } finally {
            if (wasInterrupted) {
                mLooperThread.interrupt();
            }
        }
        return true;
    }