[PATCH] Large forward shift in system time causes huge amounts of cyrus processes

Menno Smits menno at netbox.biz
Thu Apr 3 02:02:26 EST 2003


I noticed a problem with Cyrus re changes in the system date/time. If
the system time is suddenly advanced forward Cyrus will spawn many
children to handle the events it has "missed". This can result in
total starvation of resources (out of memory), especially if the time
change covers several years. 

To see this behaviour, try the following two commands:

% date -s "2002-01-01 00:00"
% date -s "2004-01-01 00:00"

Cyrus will soon generate thousands of processes and bring the system
to a grinding halt :)

Included below is a simple patch for 2.1.11 which fixes the problem.
Application to 2.1.12 should be similar.

---< SNIP >----------------------------------------------------------

--- cyrus-imapd-2.1.11/master/master.c.orig     Mon Mar 10 12:52:28 2003
+++ cyrus-imapd-2.1.11/master/master.c  Mon Mar 10 12:55:26 2003
@@ -687,7 +687,14 @@
        /* reschedule as needed */
        b = a->next;
        if (a->period) {
-           a->mark += a->period;
+
+           if (a->mark + a->period > now)
+               a->mark += a->period;
+           else
+               a->mark = now + a->period;
+
            /* reschedule a */
            schedule_event(a);
        } else {

---< SNIP >----------------------------------------------------------

Note that this doesn't deal with *backwards* shifts in the system
clock althought the ramifications aren't *quite* as serious. Cyrus
just won't execute any events until the time before the time shift
occured is reached. This wouldn't be too hard to fix but backwards
shifts never happens in my situation so I didn't bother.

-- 
Menno Smits (B.Info.Tech. B.Eng.(M.E.) Hons)
Senior Development Engineer
NetBox | Oxcoda
E-mail: menno at netbox.biz
Web: netbox.biz




More information about the Info-cyrus mailing list