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

Commit eb9b9802 authored by Mark Fasheh's avatar Mark Fasheh
Browse files

Fix broken synchronization in CombinedMessageQueue:dispatchEvents

Test: boot phone
Test: atest MessageQueueTest
Bug: 336880969
Flag: build.RELEASE_PACKAGE_MESSAGEQUEUE_IMPLEMENTATION
Change-Id: I42cb60076abec64ae41c4b1477710a0309ad0a1b
parent 53b2c23a
Loading
Loading
Loading
Loading
+20 −7
Original line number Diff line number Diff line
@@ -431,6 +431,18 @@ public final class MessageQueue {
        // Update the file descriptor record if the listener changed the set of
        // events to watch and the listener itself hasn't been updated since.
        if (newWatchedEvents != oldWatchedEvents) {
            if (mUseConcurrent) {
                synchronized (mFileDescriptorRecordsLock) {
                    int index = mFileDescriptorRecords.indexOfKey(fd);
                    if (index >= 0 && mFileDescriptorRecords.valueAt(index) == record
                            && record.mSeq == seq) {
                        record.mEvents = newWatchedEvents;
                        if (newWatchedEvents == 0) {
                            mFileDescriptorRecords.removeAt(index);
                        }
                    }
                }
            } else {
                synchronized (this) {
                    int index = mFileDescriptorRecords.indexOfKey(fd);
                    if (index >= 0 && mFileDescriptorRecords.valueAt(index) == record
@@ -442,6 +454,7 @@ public final class MessageQueue {
                    }
                }
            }
        }

        // Return the new set of events to watch for native code to take care of.
        return newWatchedEvents;