Skip to content

Commit

Permalink
If we fail to suspend/resume, assume we need to disconnect/reconnect …
Browse files Browse the repository at this point in the history
…to the mmap
  • Loading branch information
Isaac Connor committed Jun 14, 2021
1 parent da20845 commit d221d6a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}

Expand Down

0 comments on commit d221d6a

Please sign in to comment.