From 97c5a96c702c04c6f1f81799c5b7e6fb39352cd0 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 13 Jul 2022 15:23:01 -0400 Subject: [PATCH] Fix management of mRunScheduled state in reporting engine. Without this change, we can schedule a reporting run, then do a sync Run (due to urgent events), then (unnecessarily) schedule another reporting run. --- src/app/reporting/Engine.cpp | 3 +-- src/app/reporting/Engine.h | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/app/reporting/Engine.cpp b/src/app/reporting/Engine.cpp index 5e329ccf4e1c4d..702b881c18e031 100644 --- a/src/app/reporting/Engine.cpp +++ b/src/app/reporting/Engine.cpp @@ -539,6 +539,7 @@ CHIP_ERROR Engine::BuildAndSendSingleReportData(ReadHandler * apReadHandler) void Engine::Run(System::Layer * aSystemLayer, void * apAppState) { Engine * const pEngine = reinterpret_cast(apAppState); + pEngine->mRunScheduled = false; pEngine->Run(); } @@ -575,8 +576,6 @@ void Engine::Run() InteractionModelEngine * imEngine = InteractionModelEngine::GetInstance(); - mRunScheduled = false; - // We may be deallocating read handlers as we go. Track how many we had // initially, so we make sure to go through all of them. size_t initialAllocated = imEngine->mReadHandlers.Allocated(); diff --git a/src/app/reporting/Engine.h b/src/app/reporting/Engine.h index b8e8d9abb61a56..cb25b85d0b873b 100644 --- a/src/app/reporting/Engine.h +++ b/src/app/reporting/Engine.h @@ -69,11 +69,6 @@ class Engine void SetMaxAttributesPerChunk(uint32_t aMaxAttributesPerChunk) { mMaxAttributesPerChunk = aMaxAttributesPerChunk; } #endif - /** - * Main work-horse function that executes the run-loop. - */ - void Run(); - /** * Should be invoked when the device receives a Status report, or when the Report data request times out. * This allows the engine to do some clean-up. @@ -131,6 +126,11 @@ class Engine #endif private: + /** + * Main work-horse function that executes the run-loop. + */ + void Run(); + friend class TestReportingEngine; struct AttributePathParamsWithGeneration : public AttributePathParams