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; }