From 8da5a1d2c9be288d45351ceb4e98fe7d81e68f74 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 14 Jun 2021 13:30:37 -0400 Subject: [PATCH] If we fail to suspend/resume, assume we need to disconnect/reconnect to the mmap --- scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm b/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm index 3226ac2d0..629a8960b 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm @@ -286,8 +286,12 @@ sub suspendMotionDetection { usleep(100000); $count -= 1; } - ZoneMinder::Logger::Error('Unable to suspend motion detection after 5 seconds.') if !$count; - ZoneMinder::Logger::Debug(1, ZoneMinder::Memory::zmMemRead($self, 'shared_data:active', 1)); + if (!$count) { + ZoneMinder::Logger::Error('Unable to suspend motion detection after 5 seconds.'); + ZoneMinder::Memory::zmMemInvalidate($self); # Close our file handle to the zmc process we are about to end + } else { + ZoneMinder::Logger::Debug(1, 'shared_data:active='.ZoneMinder::Memory::zmMemRead($self, 'shared_data:active', 1)); + } } sub resumeMotionDetection { @@ -297,8 +301,13 @@ sub resumeMotionDetection { while ($count and !ZoneMinder::Memory::zmMemRead($self, 'shared_data:active', 1)) { ZoneMinder::Logger::Debug(1, 'Resuming motion detection'); ZoneMinder::Memory::zmMonitorResume($self); + usleep(100000); + $count -= 1; + } + if (!$count) { + ZoneMinder::Logger::Error('Unable to resume motion detection after 5 seconds.'); + ZoneMinder::Memory::zmMemInvalidate($self); # Close our file handle to the zmc process we are about to end } - ZoneMinder::Logger::Error('Unable to suspend motion detection after 5 seconds.') if !$count; return 1; }