don@hscfvax.UUCP (03/05/84)
Subject: two bugs in at Index: usr.bin/at 4.2BSD Description: (1) at's date algorithm is wrong .07% of the time: it thinks the julian date of March 1st in leap years is 60, not 61 (it screwed up our accounting last month) (2) if you try to queue more than 100 jobs at a single time, it loops (patiently looking for an unused 2-digit sequence) Repeat-By: (1) unless you lie to Unix about today's date you'll have to wait four years (2) just try it Fix: 19a20,21 > #define MAXJOBS 20 /* max no. of jobs queued in a particular minute */ > 282a285,286 > if (detail->tm_year%4==0 && found > 1) > uday += 1; 285,286d288 < if (detail->tm_year%4==0 && uday>59) < uday += 1; 336,341c338,357 < for (i=0; ; i += 53) { < sprintf(fname, "%s/%02d.%03d.%04d.%02d", dir, y, d, t, < (getpid()+i)%100); < if (access(fname, 0) == -1) < return; < } --- > for(;;){ > for (i = 0; i < MAXJOBS; i++) { > sprintf(fname, "%s/%02d.%03d.%04d.%02d", dir, y, d, t, i); > if (access(fname, 0) == -1) > return; > } > > /* come here if there are > MAXJOBS requests for the same time: > ** move to the next minute */ > > if(++t < 2400) > continue; > t = 0; > if(++d <= 365 + (y%4 == 0)) /* or day, if necessary */ > continue; > d = 0; > if(++y < 100) /* or year */ > continue; > y = 0; /* or century */ > }