From b7aa11f10924e63312385e09d37c76ed75a111f8 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 7 Sep 2018 16:30:24 -0400 Subject: [PATCH] Fix infinite loop reconnecting to db in Logging --- scripts/ZoneMinder/lib/ZoneMinder/Logger.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm b/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm index bac118a13..48e39e70e 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm @@ -440,7 +440,7 @@ sub databaseLevel { if ( defined($databaseLevel) ) { $databaseLevel = $this->limit($databaseLevel); if ( $this->{databaseLevel} != $databaseLevel ) { - if ( $databaseLevel > NOLOG and $this->{databaseLevel} <= NOLOG ) { + if ( ( $databaseLevel > NOLOG ) and ( $this->{databaseLevel} <= NOLOG ) ) { if ( !$this->{dbh} ) { $this->{dbh} = ZoneMinder::Database::zmDbConnect(); } @@ -560,11 +560,14 @@ sub logPrint { if ( $level <= $this->{databaseLevel} ) { if ( ! ( $this->{dbh} and $this->{dbh}->ping() ) ) { $this->{sth} = undef; + # Turn this off because zDbConnect will do logging calls. + my $oldlevel = $this->{databaseLevel}; + $this->{databaseLevel} = NOLOG; if ( ! ( $this->{dbh} = ZoneMinder::Database::zmDbConnect() ) ) { #print(STDERR "Can't log to database: "); - $this->{databaseLevel} = NOLOG; return; } + $this->{databaseLevel} = $oldlevel; } my $sql = 'INSERT INTO Logs ( TimeKey, Component, Pid, Level, Code, Message, File, Line ) VALUES ( ?, ?, ?, ?, ?, ?, ?, NULL )';