summaryrefslogtreecommitdiffstats
path: root/src/schedule.c
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2021-03-11 09:40:04 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-03-11 12:22:36 +0100
commite68fefeac780e6c87c6ca4722027288356eb0cc8 (patch)
treea98162b964caa2d42157d526b5eb35955bd3013b /src/schedule.c
parent76e6375720d12a7784e4784bb08b2e0050bdcf45 (diff)
#997 Set stale check flag when processing schedule/create
If you schedule a command in the past, the scheduler executes such command immediately. When expanding a schedule that result in commands that run weekly, commands in the past are also executed, which is not expected. Fix this by using the check_stale flag (formerly on_start) so commands in the past that result from expansions are skipped.
Diffstat (limited to 'src/schedule.c')
-rw-r--r--src/schedule.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/schedule.c b/src/schedule.c
index 6dc54e0..9fb272c 100644
--- a/src/schedule.c
+++ b/src/schedule.c
@@ -212,7 +212,7 @@ static void og_schedule_create_weekdays(int month, int year,
int *hours, int minutes, int week_days,
uint32_t task_id, uint32_t schedule_id,
enum og_schedule_type type,
- bool on_start)
+ bool check_stale)
{
struct og_schedule *schedule;
int month_days[5];
@@ -244,7 +244,7 @@ static void og_schedule_create_weekdays(int month, int year,
tm.tm_min = minutes;
seconds = mktime(&tm);
- if (on_start && og_schedule_stale(seconds))
+ if (check_stale && og_schedule_stale(seconds))
continue;
schedule = (struct og_schedule *)
@@ -265,7 +265,7 @@ static void og_schedule_create_weekdays(int month, int year,
static void og_schedule_create_weeks(int month, int year,
int *hours, int minutes, int weeks,
uint32_t task_id, uint32_t schedule_id,
- enum og_schedule_type type, bool on_start)
+ enum og_schedule_type type, bool check_stale)
{
struct og_schedule *schedule;
int month_days[7];
@@ -300,7 +300,7 @@ static void og_schedule_create_weeks(int month, int year,
tm.tm_min = minutes;
seconds = mktime(&tm);
- if (on_start && og_schedule_stale(seconds))
+ if (check_stale && og_schedule_stale(seconds))
continue;
schedule = (struct og_schedule *)
@@ -321,7 +321,7 @@ static void og_schedule_create_weeks(int month, int year,
static void og_schedule_create_days(int month, int year,
int *hours, int minutes, int *days,
uint32_t task_id, uint32_t schedule_id,
- enum og_schedule_type type, bool on_start)
+ enum og_schedule_type type, bool check_stale)
{
struct og_schedule *schedule;
time_t seconds;
@@ -339,7 +339,7 @@ static void og_schedule_create_days(int month, int year,
tm.tm_min = minutes;
seconds = mktime(&tm);
- if (on_start && og_schedule_stale(seconds))
+ if (check_stale && og_schedule_stale(seconds))
continue;
schedule = (struct og_schedule *)
@@ -385,7 +385,7 @@ void og_schedule_create(unsigned int schedule_id, unsigned int task_id,
task_id,
schedule_id,
type,
- time->on_start);
+ time->check_stale);
if (time->weeks)
og_schedule_create_weeks(month, year,
@@ -393,7 +393,7 @@ void og_schedule_create(unsigned int schedule_id, unsigned int task_id,
time->weeks,
task_id,
schedule_id,
- type, time->on_start);
+ type, time->check_stale);
if (time->days)
og_schedule_create_days(month, year,
@@ -401,7 +401,7 @@ void og_schedule_create(unsigned int schedule_id, unsigned int task_id,
days,
task_id,
schedule_id,
- type, time->on_start);
+ type, time->check_stale);
}
}