Skip to content

Commit 912b181

Browse files
Use get_packet_no_wait and a sleep so that if told to close we give up on getting a packet
1 parent 79a8e96 commit 912b181

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/zm_event.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ void Event::Run() {
686686
// The idea is to process the queue no matter what so that all packets get processed.
687687
// We only break if the queue is empty
688688
while (!terminate_ and !zm_terminate) {
689-
ZMLockedPacket *packet_lock = packetqueue->get_packet(packetqueue_it);
689+
ZMLockedPacket *packet_lock = packetqueue->get_packet_no_wait(packetqueue_it);
690690
if (packet_lock) {
691691
std::shared_ptr<ZMPacket> packet = packet_lock->packet_;
692692
if (!packet->decoded) {
@@ -721,7 +721,8 @@ void Event::Run() {
721721
// Important not to increment it until after we are done with the packet because clearPackets checks for iterators pointing to it.
722722
packetqueue->increment_it(packetqueue_it);
723723
} else {
724-
return;
724+
if (terminate_ or zm_terminate) return;
725+
usleep(10000);
725726
} // end if packet_lock
726727
} // end while
727728
} // end Run()

0 commit comments

Comments
 (0)