Skip to content

Commit

Permalink
Fix management of mRunScheduled state in reporting engine. (#20694)
Browse files Browse the repository at this point in the history
Without this change, we can schedule a reporting run, then do a sync
Run (due to urgent events), then (unnecessarily) schedule another
reporting run.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Dec 5, 2023
1 parent 3a8d405 commit d5be4e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/app/reporting/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ CHIP_ERROR Engine::BuildAndSendSingleReportData(ReadHandler * apReadHandler)
void Engine::Run(System::Layer * aSystemLayer, void * apAppState)
{
Engine * const pEngine = reinterpret_cast<Engine *>(apAppState);
pEngine->mRunScheduled = false;
pEngine->Run();
}

Expand Down Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions src/app/reporting/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand 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
Expand Down

0 comments on commit d5be4e3

Please sign in to comment.