From 816123f6ef9c5f2501dd2b5e746d1c6c6996697f Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 25 Feb 2020 17:45:07 +0100 Subject: [PATCH] Changed logic of inverted interval management --- pandora_agents/unix/pandora_agent | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 1257dc9153..1912598406 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -2621,7 +2621,7 @@ sub cron_next_execution { $nex_time = cron_next_execution_date ($cron, $nex_time, 0); } - return $nex_time - time(); + return $nex_time - $cur_time; } ############################################################################### @@ -2652,7 +2652,7 @@ sub cron_check_interval { if ($down < $up) { return 0 if ($elem_curr_time < $down || $elem_curr_time > $up); } else { - return 0 if ($elem_curr_time > $down || $elem_curr_time < $up); + return 0 if ($elem_curr_time < $down && $elem_curr_time > $up); } return 1; @@ -2676,15 +2676,11 @@ sub cron_next_execution_date { } } - # Get current time - if (! defined ($cur_time)) { - $cur_time = time(); - } # Check if current time + interval is on cron too my $nex_time = $cur_time + $interval; my ($cur_min, $cur_hour, $cur_mday, $cur_mon, $cur_year) = (localtime ($nex_time))[1, 2, 3, 4, 5]; - + my @cron_array = ($min, $hour, $mday, $mon); my @curr_time_array = ($cur_min, $cur_hour, $cur_mday, $cur_mon); return ($nex_time) if cron_is_in_cron(\@cron_array, \@curr_time_array) == 1; @@ -2821,7 +2817,7 @@ sub cron_is_in_cron { # * should returns floor data. # 5 should returns 5. # 10-55 should returns 10. -# 55-10 should retunrs floor data. +# 55-10 should returns elem_down. ################################################################################ sub cron_get_next_time_element { # Default floor data is 0 @@ -2829,7 +2825,7 @@ sub cron_get_next_time_element { $floor_data = 0 unless defined($floor_data); my ($elem_down, $elem_up) = cron_get_interval ($curr_element); - return ($elem_down eq '*' || (defined($elem_up) && $elem_down > $elem_up)) + return ($elem_down eq '*') ? $floor_data : $elem_down; }