From 912b1818b7465eb914b2170e0e81518150bc8d6c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 1 Aug 2024 18:01:28 -0400 Subject: [PATCH] Use get_packet_no_wait and a sleep so that if told to close we give up on getting a packet --- src/zm_event.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index a6cff949dd..56f17deb93 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -686,7 +686,7 @@ void Event::Run() { // The idea is to process the queue no matter what so that all packets get processed. // We only break if the queue is empty while (!terminate_ and !zm_terminate) { - ZMLockedPacket *packet_lock = packetqueue->get_packet(packetqueue_it); + ZMLockedPacket *packet_lock = packetqueue->get_packet_no_wait(packetqueue_it); if (packet_lock) { std::shared_ptr packet = packet_lock->packet_; if (!packet->decoded) { @@ -721,7 +721,8 @@ void Event::Run() { // Important not to increment it until after we are done with the packet because clearPackets checks for iterators pointing to it. packetqueue->increment_it(packetqueue_it); } else { - return; + if (terminate_ or zm_terminate) return; + usleep(10000); } // end if packet_lock } // end while } // end Run()