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

Commit 72547ba2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix race in removeSyncBarrier that would cause a missing wakeup" into main

parents cf15e4d9 a443f035
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -1273,16 +1273,12 @@ public final class MessageQueue {
        boolean removed;
        final MatchBarrierToken matchBarrierToken = new MatchBarrierToken(token);

        // Retain the first element to see if we are currently stuck on a barrier.
        final Message m = first(mPriorityQueue);

        removed = findOrRemoveMessages(null, 0, null, null, 0, matchBarrierToken, true);
        if (removed && m != null) {
            if (m.target == null && m.arg1 == token) {
                /* Wake up next() in case it was sleeping on this barrier. */
        if (removed) {
            // Wake up next() in case it was sleeping on this barrier.
            // TODO(b/427541521): optimize wakeup logic to only wake up if we are blocked.
            concurrentWake();
            }
        } else if (!removed) {
        } else {
            throw new IllegalStateException("The specified message queue synchronization "
                    + " barrier token has not been posted or has already been removed.");
        }