Add a lambda to prevent spurious wakeups

This commit is contained in:
Isaac Connor
2026-01-16 12:11:42 -05:00
parent 1a3e36424e
commit 5561041c70

View File

@@ -336,6 +336,7 @@ void PacketQueue::clearPackets(const std::shared_ptr<ZMPacket> &add_packet) {
while (*it != add_packet) {
zm_packet = *it;
{
// We are only locking it to see if anyone else is messing with it.
ZMPacketLock packet_lock(zm_packet);
if (!packet_lock.trylock()) {
Debug(3, "Failed locking packet %d", zm_packet->image_index);
@@ -476,7 +477,7 @@ ZMPacketLock PacketQueue::get_packet_no_wait(packetqueue_iterator *it) {
return ZMPacketLock();
if ((*it == pktQueue.end()) and !(deleting or zm_terminate)) {
Debug(2, "waiting. Queue size %zu it == end? %d", pktQueue.size(), (*it == pktQueue.end()));
condition.wait(lck);
condition.wait(lck, [&]{ return (*it != pktQueue.end()) || deleting || zm_terminate; });
}
if ((*it == pktQueue.end()) or deleting or zm_terminate) return ZMPacketLock();