diff --git a/build/bytetrack-counter b/build/bytetrack-counter index 0e98bb6..e9b43a2 100755 Binary files a/build/bytetrack-counter and b/build/bytetrack-counter differ diff --git a/src/batch_store.cpp b/src/batch_store.cpp index e7ff508..3c2f733 100644 --- a/src/batch_store.cpp +++ b/src/batch_store.cpp @@ -191,10 +191,11 @@ void BatchStore::start_new_batch(const std::string& counting_date) { void BatchStore::reset_batch_timer() { batch_timer_running_ = true; + uint64_t gen = ++batch_timer_gen_; if (batch_timer_thread_.joinable()) batch_timer_thread_.detach(); - batch_timer_thread_ = std::thread([this]() { + batch_timer_thread_ = std::thread([this, gen]() { auto start = std::chrono::steady_clock::now(); - while (batch_timer_running_) { + while (batch_timer_gen_ == gen && batch_timer_running_) { auto elapsed = std::chrono::duration_cast( std::chrono::steady_clock::now() - start).count(); if (elapsed >= batch_timeout_) { @@ -409,7 +410,6 @@ void BatchStore::start_cutoff_watcher() { void BatchStore::ping_activity() { std::lock_guard lock(state_mutex_); if (!current_state_.is_null()) { - current_state_["last_detection_time"] = now_iso(); reset_batch_timer(); } } diff --git a/src/batch_store.hpp b/src/batch_store.hpp index 16d56b5..d0cd719 100644 --- a/src/batch_store.hpp +++ b/src/batch_store.hpp @@ -71,6 +71,7 @@ private: std::thread batch_timer_thread_; std::thread ignore_label_thread_; std::atomic batch_timer_running_{false}; + std::atomic batch_timer_gen_{0}; std::atomic ignore_label_active_{false}; std::atomic shutdown_flag_{false}; std::atomic ignore_batch_label_{false};