From a0fd8d64d221d41a460144bcd9c0a02e298c6cb1 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 9 Dec 2021 12:33:59 -0500 Subject: [PATCH] Wait for closeEvent thread to finish. Fixes unfinished event when zmc told to restart --- src/zm_monitor.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 5d1cd1792..40de77f67 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -3096,9 +3096,6 @@ int Monitor::PrimeCapture() { int Monitor::PreCapture() const { return camera->PreCapture(); } int Monitor::PostCapture() const { return camera->PostCapture(); } int Monitor::Close() { - if (close_event_thread.joinable()) { - close_event_thread.join(); - } // Because the stream indexes may change we have to clear out the packetqueue if (decoder) { decoder->Stop(); @@ -3116,10 +3113,14 @@ int Monitor::Close() { video_fifo = nullptr; } + if (close_event_thread.joinable()) { + close_event_thread.join(); + } std::lock_guard lck(event_mutex); if (event) { Info("%s: image_count:%d - Closing event %" PRIu64 ", shutting down", name.c_str(), image_count, event->Id()); closeEvent(); + close_event_thread.join(); } if (camera) camera->Close(); return 1;