From bc0b20ad1f0b63a12f8f56ca5e53055bddd2680c Mon Sep 17 00:00:00 2001 From: Stan Rokita Date: Wed, 15 Jan 2020 08:12:45 -0800 Subject: [PATCH] Decrement size of pending write queue by correct amount The pending write events vector is destructed before using its size to decrement the number of events on the pending write events queue which may cause the value decrement by 0 instead of the actual number of events removed. Bug: 147686560 Test: Build and load onto device with fake subhals Change-Id: I7b6c6231eacfa89b0dd55bc405b235d34be5ff46 --- sensors/2.0/multihal/HalProxy.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sensors/2.0/multihal/HalProxy.cpp b/sensors/2.0/multihal/HalProxy.cpp index 03ff6051a8..fd76bda726 100644 --- a/sensors/2.0/multihal/HalProxy.cpp +++ b/sensors/2.0/multihal/HalProxy.cpp @@ -486,15 +486,14 @@ void HalProxy::handlePendingWrites() { } } lock.lock(); + mSizePendingWriteEventsQueue -= numToWrite; if (pendingWriteEvents.size() > eventQueueSize) { // TODO(b/143302327): Check if this erase operation is too inefficient. It will copy // all the events ahead of it down to fill gap off array at front after the erase. pendingWriteEvents.erase(pendingWriteEvents.begin(), pendingWriteEvents.begin() + eventQueueSize); - mSizePendingWriteEventsQueue -= eventQueueSize; } else { mPendingWriteEventsQueue.pop(); - mSizePendingWriteEventsQueue -= pendingWriteEvents.size(); } } }