On Thu, Mar 12, 2009 at 09:27:27AM -0700, Andrew Morgan wrote: > On Thu, 12 Mar 2009, Adam Tauno Williams wrote: > > > I have - > > delprune cmd="cyr_expire -E 3 -D 120 -X 120" at=0400 > > - so cyr_expire should run at 4:00, right? > > > > But it runs at 5:00. The time on the server is correct. Could daylight > > savings time change effect this? > > Yes, all of your "at=xyz" events will be off an hour until you restart > cyrus. I found this bug a long time ago and basically ignored it. :) Something like this should fix it. I'll test it and commit... Bron.
diff --git a/master/master.c b/master/master.c index 5780de2..ea8150c 100644 --- a/master/master.c +++ b/master/master.c @@ -144,6 +144,8 @@ struct event { char *name; time_t mark; time_t period; + time_t hour; + time_t min; int periodic; char *const *exec; struct event *next; @@ -774,9 +776,26 @@ void spawn_schedule(time_t now) if(a->periodic) { a->mark = now + a->period; } else { + struct tm *tm; + int delta; /* Daily Event */ while(a->mark <= now) { - a->mark += a->period; + a->mark += a->period; + } + /* check for daylight savings fuzz... */ + tm = localtime(&(a->mark)); + if (tm->tm_hour != a->hour || tm->tm_min != a->min) { + /* calculate the same time on the new day */ + tm->tm_hour = a->hour; + tm->tm_min = a->min; + delta = mktime(tm) - a->mark; + /* bring it within half a period either way */ + while (delta > (a->period/2)) delta -= a->period; + while (delta < -(a->period/2)) delta += a->period; + /* update the time */ + a->mark += delta; + /* and let us know about the change */ + syslog(LOG_NOTICE, "timezone shift for %s - altering schedule by %d seconds", a->name, delta); } } /* reschedule a */ @@ -1450,6 +1469,8 @@ void add_event(const char *name, struct entry *e, void *rock) period = 86400; /* 24 hours */ evt->periodic = 0; + evt->hour = hour; + evt->min = min; tm->tm_hour = hour; tm->tm_min = min; tm->tm_sec = 0;
---- Cyrus Home Page: http://cyrusimap.web.cmu.edu/ Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html