diff --git a/src/fne/network/TrafficNetwork.MetricsLogging.cpp b/src/fne/network/TrafficNetwork.MetricsLogging.cpp index 37c8a341..cf356e76 100644 --- a/src/fne/network/TrafficNetwork.MetricsLogging.cpp +++ b/src/fne/network/TrafficNetwork.MetricsLogging.cpp @@ -802,7 +802,6 @@ namespace { std::string threadName("fne:sqlite"); if (g_killed) { - delete th; return nullptr; } @@ -811,9 +810,12 @@ namespace { ::pthread_setname_np(th->thread, threadName.c_str()); #endif // _GNU_SOURCE - while (!g_killed) { + while (true) { size_t queueDepth = state->queue.pendingCount.load(std::memory_order_acquire); if (queueDepth == 0U) { + if (state->stopRequested.load(std::memory_order_acquire)) { + break; + } std::this_thread::sleep_for(std::chrono::milliseconds(SQLITE_BATCH_WAIT_MS)); continue; } @@ -880,7 +882,6 @@ namespace { } LogInfoEx(LOG_HOST, "[STOP] %s", threadName.c_str()); - delete th; return nullptr; }