From e5de77084e92436c0fc75615002bdcb92f112deb Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Thu, 16 Jul 2020 17:27:56 +0200 Subject: [PATCH] Add a simple reentrancy guard Due to the use of sub-processes during the tile generation we re-enter the event loop, and thus might receive another socket notification while the previous one is still being processed. --- tools/vectorosm-tilecreator/tirexbackend.cpp | 6 ++++++ tools/vectorosm-tilecreator/tirexbackend.h | 1 + 2 files changed, 7 insertions(+) diff --git a/tools/vectorosm-tilecreator/tirexbackend.cpp b/tools/vectorosm-tilecreator/tirexbackend.cpp index 7bc1ddabf..2798aa679 100644 --- a/tools/vectorosm-tilecreator/tirexbackend.cpp +++ b/tools/vectorosm-tilecreator/tirexbackend.cpp @@ -7,6 +7,7 @@ #include "tirexbackend.h" #include +#include #include #include @@ -50,6 +51,11 @@ TirexBackend::~TirexBackend() = default; void TirexBackend::commandReadyRead() { + if (m_recursionLock) { + return; + } + QScopedValueRollback lock(m_recursionLock, true); + while (true) { m_renderTime.restart(); TirexMetatileRequest req; diff --git a/tools/vectorosm-tilecreator/tirexbackend.h b/tools/vectorosm-tilecreator/tirexbackend.h index 5d8658910..3e136b00d 100644 --- a/tools/vectorosm-tilecreator/tirexbackend.h +++ b/tools/vectorosm-tilecreator/tirexbackend.h @@ -86,6 +86,7 @@ private: QString m_tileDir; QElapsedTimer m_renderTime; int m_heartbeatFd = -1; + bool m_recursionLock = false; static constexpr const int m_metatileRows = 8; // TODO read from config eventually static constexpr const int m_metatileCols = 8; }; -- GitLab