mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-05-18 11:35:15 -04:00
fix: resolve Event::Run thread hang preventing zmc clean shutdown
Event::Run could block indefinitely in PacketQueue methods during normal event closing (closeEvent from analysis thread), because their wait predicates only check deleting/zm_terminate, not Event's terminate_ flag. Three changes fix this: - get_packet_no_wait: return immediately when iterator at end instead of blocking on condition variable (makes it truly non-blocking) - Event::Run: use increment_it(wait=false) since deletePacket can advance the iterator to end() during AddPacket_ without the queue lock - Event::Stop: call packetqueue->notify_all() to wake timed waits so Run() checks terminate_ promptly Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -475,11 +475,8 @@ ZMPacketLock PacketQueue::get_packet_no_wait(packetqueue_iterator *it) {
|
||||
std::addressof(*it), (*it == pktQueue.end()));
|
||||
if (deleting or zm_terminate)
|
||||
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, [&]{ return (*it != pktQueue.end()) || deleting || zm_terminate; });
|
||||
}
|
||||
if ((*it == pktQueue.end()) or deleting or zm_terminate) return ZMPacketLock();
|
||||
if (*it == pktQueue.end())
|
||||
return ZMPacketLock();
|
||||
|
||||
std::shared_ptr<ZMPacket> p = *(*it);
|
||||
ZMPacketLock packet_lock(p);
|
||||
|
||||
Reference in New Issue
Block a user