Skip to content

Commit

Permalink
fix(plugin-events): fix race condition when requesting event updates (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyTWF committed Jul 29, 2021
1 parent e061d6a commit 5da1b7c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/push/PollingPushEventConnection.cpp
Expand Up @@ -58,16 +58,17 @@ namespace UKControllerPlugin {
return;
}

this->syncInProgress = true;
this->taskRunner.QueueAsynchronousTask(
[this]()
{
this->syncInProgress = true;
try {
nlohmann::json syncResponse = this->api.SyncPluginEvents();

if (!this->SyncResponseValid(syncResponse)) {
this->lastPollTime = std::chrono::system_clock::now();
LogWarning("Invalid plugin event sync response from API");
this->updateInProgress = false;
return;
}

Expand All @@ -94,16 +95,17 @@ namespace UKControllerPlugin {
return;
}

this->updateInProgress = true;
this->taskRunner.QueueAsynchronousTask(
[this]()
{
this->updateInProgress = true;
try {
nlohmann::json latestEventsResponse = this->api.GetLatestPluginEvents(this->lastEventId);

if (!LatestPluginEventsResponseValid(latestEventsResponse)) {
LogWarning("Invalid plugin events response from API");
this->lastPollTime = std::chrono::system_clock::now();
this->updateInProgress = false;
return;
}

Expand Down

0 comments on commit 5da1b7c

Please sign in to comment.