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

Commit 481885c5 authored by Chia-I Wu's avatar Chia-I Wu Committed by android-build-merger
Browse files

Merge "graphics: discard stale data from message queue" into oc-mr1-dev

am: 710b7085

Change-Id: I2a2e69edf9e822b4bd44344163f79b7d036d95c3
parents 5ada5a66 710b7085
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -92,6 +92,23 @@ public:
    bool writeQueue(bool* outQueueChanged, uint32_t* outCommandLength,
            hidl_vec<hidl_handle>* outCommandHandles)
    {
        // After data are written to the queue, it may not be read by the
        // remote reader when
        //
        //  - the writer does not send them (because of other errors)
        //  - the hwbinder transaction fails
        //  - the reader does not read them (because of other errors)
        //
        // Discard the stale data here.
        size_t staleDataSize = mQueue ? mQueue->availableToRead() : 0;
        if (staleDataSize > 0) {
            ALOGW("discarding stale data from message queue");
            CommandQueueType::MemTransaction tx;
            if (mQueue->beginRead(staleDataSize, &tx)) {
                mQueue->commitRead(staleDataSize);
            }
        }

        // write data to queue, optionally resizing it
        if (mQueue && (mDataMaxSize <= mQueue->getQuantumCount())) {
            if (!mQueue->write(mData.get(), mDataWritten)) {