cronie/cronie-1.4.6-anacron-locks.patch

135 lines
3.4 KiB
Diff
Raw Normal View History

diff --git a/anacron/global.h b/anacron/global.h
index 91963a7..0fe3f9b 100644
--- a/anacron/global.h
+++ b/anacron/global.h
@@ -42,6 +42,7 @@
#define MAX_MSG 150
#include <signal.h>
+#include <time.h>
#include "anacron-paths.h"
/* Some declarations */
@@ -102,6 +103,8 @@ extern int running_jobs,running_mailers;
extern int complaints;
+extern time_t start_sec;
+
/* time ranges for START_HOURS_RANGE */
extern int range_start;
extern int range_stop;
diff --git a/anacron/lock.c b/anacron/lock.c
index 68fd252..71aae09 100644
--- a/anacron/lock.c
+++ b/anacron/lock.c
@@ -94,6 +94,9 @@ consider_job(job_rec *jr)
if (!force && b == 8)
{
int day_delta;
+ time_t jobtime;
+ struct tm *t;
+
if (sscanf(timestamp, "%4d%2d%2d", &ts_year, &ts_month, &ts_day) == 3)
dn = day_num(ts_year, ts_month, ts_day);
else
@@ -149,6 +152,18 @@ consider_job(job_rec *jr)
return 0;
}
}
+
+ jobtime = start_sec + jr->delay * 60;
+
+ t = localtime(&jobtime);
+ if (!now && range_start != -1 && range_stop != -1 &&
+ (t->tm_hour < range_start || t->tm_hour >= range_stop))
+ {
+ Debug(("The job `%s' falls out of the %02d:00-%02d:00 hours range, skipping.",
+ jr->ident, range_start, range_stop));
+ xclose (jr->timestamp_fd);
+ return 0;
+ }
}
/* no! try to grab the lock */
diff --git a/anacron/main.c b/anacron/main.c
index 2fd3ed5..08db810 100644
--- a/anacron/main.c
+++ b/anacron/main.c
@@ -55,7 +55,7 @@ sigset_t old_sigmask; /* signal mask when started */
job_rec *first_job_rec;
env_rec *first_env_rec;
-static time_t start_sec; /* time anacron started */
+time_t start_sec; /* time anacron started */
static volatile int got_sigalrm, got_sigchld, got_sigusr1;
int running_jobs, running_mailers; /* , number of */
int range_start = -1;
@@ -406,7 +406,6 @@ static void
explain_intentions()
{
int j;
- struct tm *t;
j = 0;
while (j < njobs)
@@ -417,21 +416,8 @@ explain_intentions()
}
else
{
- time_t jobtime = start_sec + job_array[j]->delay * 60;
-
- t = localtime(&jobtime);
- if (range_start != -1 && range_stop != -1 &&
- (t->tm_hour < range_start || t->tm_hour >= range_stop))
- {
- Debug(("The job `%s' falls out of the %02d:00-%02d:00 hours range, skipping.",
- job_array[j]->ident, range_start, range_stop));
- job_array[j]->drop_job = 1;
- }
- else
- {
- explain("Will run job `%s' in %d min.",
+ explain("Will run job `%s' in %d min.",
job_array[j]->ident, job_array[j]->delay);
- }
}
j++;
}
@@ -443,15 +429,12 @@ int
main(int argc, char *argv[])
{
int j;
-
int cwd;
-
- int dropped_jobs = 0;
+ struct timeval tv;
+ struct timezone tz;
anacrontab = NULL;
spooldir = NULL;
- struct timeval tv;
- struct timezone tz;
if (gettimeofday(&tv, &tz) != 0)
explain("Can't get exact time, failure.");
@@ -514,16 +497,11 @@ main(int argc, char *argv[])
running_jobs = running_mailers = 0;
for(j = 0; j < njobs; ++j)
{
- if (job_array[j]->drop_job == 1)
- {
- ++dropped_jobs;
- continue;
- }
xsleep(time_till(job_array[j]));
if (serialize) wait_jobs();
launch_job(job_array[j]);
}
wait_children();
- explain("Normal exit (%d job%s run)", njobs-dropped_jobs, (njobs-dropped_jobs == 1 ? "" : "s"));
+ explain("Normal exit (%d job%s run)", njobs, njobs == 1 ? "" : "s");
exit(0);
}