Skip to content

Commit

Permalink
Use get_packet_no_wait and a sleep so that if told to close we give u…
Browse files Browse the repository at this point in the history
…p on getting a packet
  • Loading branch information
Isaac Connor committed Aug 1, 2024
1 parent 79a8e96 commit 912b181
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/zm_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ZMPacket> packet = packet_lock->packet_;
if (!packet->decoded) {
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 912b181

Please sign in to comment.