Implement per-filter delays using the ExecuteInterval member of Filters. Remove uneded lockandload when doing row locks. We will have already locked when executing the filter sql.

This commit is contained in:
Isaac Connor 2021-12-13 14:59:38 -05:00
parent 0382a677df
commit a65f2b42ce
1 changed files with 12 additions and 7 deletions

View File

@ -138,7 +138,6 @@ $ENV{PATH} = '/bin:/usr/bin:/usr/local/bin';
$ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
my $delay = $Config{ZM_FILTER_EXECUTE_INTERVAL};
my $event_id = 0;
if (!EVENT_PATH) {
@ -174,6 +173,7 @@ my @filters;
my $last_action = 0;
while (!$zm_terminate) {
my $delay = $Config{ZM_FILTER_EXECUTE_INTERVAL};
my $now = time;
if (($now - $last_action) > $Config{ZM_FILTER_RELOAD_DELAY}) {
Debug('Reloading filters');
@ -183,6 +183,15 @@ while (!$zm_terminate) {
foreach my $filter (@filters) {
last if $zm_terminate;
my $elapsed = ($now - $$filter{last_ran});
if ($$filter{last_ran} and ($elapsed < $$filter{ExecuteInterval})) {
my $filter_delay = $$filter{ExecuteInterval} - ($now - $$filter{last_ran});
$delay = $filter_delay if $filter_delay < $delay;
Debug("Setting delay to $delay because ExecuteInterval=$$filter{ExecuteInterval} and $elapsed have elapsed");
next;
}
if ($$filter{Concurrent} and !($filter_id or $filter_name)) {
my ( $proc ) = $0 =~ /(\S+)/;
my ( $id ) = $$filter{Id} =~ /(\d+)/;
@ -191,8 +200,9 @@ while (!$zm_terminate) {
system(qq`$proc --filter_id $id &`);
} else {
checkFilter($filter);
$$filter{last_ran} = $now;
}
}
} # end foreach filter
last if (!$daemon and ($filter_name or $filter_id)) or $zm_terminate;
@ -362,11 +372,6 @@ sub checkFilter {
} # end if AutoCopy
if ( $filter->{UpdateDiskSpace} ) {
if ( $$filter{LockRows} ) {
$ZoneMinder::Database::dbh->begin_work();
$Event->lock_and_load();
}
my $old_diskspace = $$Event{DiskSpace};
my $new_diskspace = $Event->DiskSpace(undef);