From a748b0ed0a7e880f93a092133d6d185f5cb7aa27 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 8 Mar 2022 09:06:06 -0500 Subject: [PATCH] When connecting to a monitor, if it fails, disconnect. This should fix a bug in zmtrigger and others where it would never reconnect. The idea is that we asked for a successful connection, if it failed, we shouldn't be in a failed connected state, we should be disconnected. --- scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm b/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm index 3a5d83d4c..89125d5b8 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm @@ -298,11 +298,16 @@ sub Event_Summary { sub connect { my $self = shift; - return ZoneMinder::Memory::zmMemVerify($self); + ZoneMinder::Logger::Debug(4, "Connecting"); + if (!ZoneMinder::Memory::zmMemVerify($self)) { + $self->disconnect(); + } + return !undef; } sub disconnect { my $self = shift; + ZoneMinder::Logger::Debug(4, "Disconnecting"); ZoneMinder::Memory::zmMemInvalidate($self); # Close our file handle to the zmc process we are about to end }