Browse Source

Plan 9 from Bell Labs 2006-07-07

David du Colombier 14 years ago
parent
commit
78bd851fb7

+ 3 - 3
dist/replica/_plan9.db

@@ -5748,7 +5748,7 @@ sys/games - 20000000775 sys sys 952648872 0
 sys/games/lib - 20000000775 sys sys 952648879 0
 sys/games/lib/4scores - 10000000666 sys sys 1118680448 0
 sys/games/lib/5scores - 10000000666 sys sys 1118680453 0
-sys/games/lib/fortunes - 664 sys sys 1151993809 259988
+sys/games/lib/fortunes - 664 sys sys 1152212060 260027
 sys/games/lib/mahjongg - 20000000775 sys sys 1095792278 0
 sys/games/lib/mahjongg/backgrounds - 20000000775 sys sys 1095792293 0
 sys/games/lib/mahjongg/backgrounds/default.bit - 664 sys sys 1095792293 346803
@@ -9457,7 +9457,7 @@ sys/src/cmd/auth/changeuser.c - 664 sys sys 1118884775 2932
 sys/src/cmd/auth/convbio.c - 664 sys sys 1015008432 2212
 sys/src/cmd/auth/convkeys.c - 664 sys sys 1140272940 2370
 sys/src/cmd/auth/convkeys2.c - 664 sys sys 1140272940 2427
-sys/src/cmd/auth/cron.c - 664 sys sys 1147439284 11681
+sys/src/cmd/auth/cron.c - 664 sys sys 1152222646 12266
 sys/src/cmd/auth/debug.c - 664 sys sys 1143694911 7325
 sys/src/cmd/auth/disable - 775 sys sys 1015008431 146
 sys/src/cmd/auth/enable - 775 sys sys 1015008430 134
@@ -9491,7 +9491,7 @@ sys/src/cmd/auth/lib/getauthkey.c - 664 sys sys 1015008430 434
 sys/src/cmd/auth/lib/getexpiration.c - 664 sys sys 1045504996 1557
 sys/src/cmd/auth/lib/keyfmt.c - 664 sys sys 1015008430 491
 sys/src/cmd/auth/lib/log.c - 664 sys sys 1015008430 601
-sys/src/cmd/auth/lib/mkfile - 664 sys sys 1035833803 381
+sys/src/cmd/auth/lib/mkfile - 664 sys sys 1152223363 386
 sys/src/cmd/auth/lib/netcheck.c - 664 sys sys 1015008430 2048
 sys/src/cmd/auth/lib/okpasswd.c - 664 sys sys 1015008430 690
 sys/src/cmd/auth/lib/querybio.c - 664 sys sys 1015008430 1344

+ 3 - 3
dist/replica/plan9.db

@@ -5748,7 +5748,7 @@ sys/games - 20000000775 sys sys 952648872 0
 sys/games/lib - 20000000775 sys sys 952648879 0
 sys/games/lib/4scores - 10000000666 sys sys 1118680448 0
 sys/games/lib/5scores - 10000000666 sys sys 1118680453 0
-sys/games/lib/fortunes - 664 sys sys 1151993809 259988
+sys/games/lib/fortunes - 664 sys sys 1152212060 260027
 sys/games/lib/mahjongg - 20000000775 sys sys 1095792278 0
 sys/games/lib/mahjongg/backgrounds - 20000000775 sys sys 1095792293 0
 sys/games/lib/mahjongg/backgrounds/default.bit - 664 sys sys 1095792293 346803
@@ -9457,7 +9457,7 @@ sys/src/cmd/auth/changeuser.c - 664 sys sys 1118884775 2932
 sys/src/cmd/auth/convbio.c - 664 sys sys 1015008432 2212
 sys/src/cmd/auth/convkeys.c - 664 sys sys 1140272940 2370
 sys/src/cmd/auth/convkeys2.c - 664 sys sys 1140272940 2427
-sys/src/cmd/auth/cron.c - 664 sys sys 1147439284 11681
+sys/src/cmd/auth/cron.c - 664 sys sys 1152222646 12266
 sys/src/cmd/auth/debug.c - 664 sys sys 1143694911 7325
 sys/src/cmd/auth/disable - 775 sys sys 1015008431 146
 sys/src/cmd/auth/enable - 775 sys sys 1015008430 134
@@ -9491,7 +9491,7 @@ sys/src/cmd/auth/lib/getauthkey.c - 664 sys sys 1015008430 434
 sys/src/cmd/auth/lib/getexpiration.c - 664 sys sys 1045504996 1557
 sys/src/cmd/auth/lib/keyfmt.c - 664 sys sys 1015008430 491
 sys/src/cmd/auth/lib/log.c - 664 sys sys 1015008430 601
-sys/src/cmd/auth/lib/mkfile - 664 sys sys 1035833803 381
+sys/src/cmd/auth/lib/mkfile - 664 sys sys 1152223363 386
 sys/src/cmd/auth/lib/netcheck.c - 664 sys sys 1015008430 2048
 sys/src/cmd/auth/lib/okpasswd.c - 664 sys sys 1015008430 690
 sys/src/cmd/auth/lib/querybio.c - 664 sys sys 1015008430 1344

+ 3 - 0
dist/replica/plan9.log

@@ -30192,3 +30192,6 @@
 1151854245 0 c sys/man/2/bio - 664 sys sys 1151854125 6546
 1151879453 0 c sys/games/lib/fortunes - 664 sys sys 1151878959 259906
 1151994688 0 c sys/games/lib/fortunes - 664 sys sys 1151993809 259988
+1152212440 0 c sys/games/lib/fortunes - 664 sys sys 1152212060 260027
+1152225005 0 c sys/src/cmd/auth/cron.c - 664 sys sys 1152222646 12266
+1152225005 1 c sys/src/cmd/auth/lib/mkfile - 664 sys sys 1152223363 386

+ 1 - 0
sys/games/lib/fortunes

@@ -4132,3 +4132,4 @@ vi vi vi - the roman number of the beast
 VFS: Busy inodes after unmount. Self-destruct in 5 seconds.  Have a nice day...  - Linux
 One of the silliest things you can do with a modern Unix machine is run the Eliza mode of Emacs against random quotes from Zippy the Pinhead.  - Eric Raymond
 * Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE DESCRIBE IT HERE!
+Never smack a Bulgarian. - Ron Minnich

+ 42 - 12
sys/src/cmd/auth/cron.c

@@ -67,13 +67,30 @@ void	printjobs(void);
 int	qidcmp(Qid, Qid);
 int	becomeuser(char*);
 
+ulong
+minute(ulong tm)
+{
+	return tm - tm%Minute;		/* round down to the minute */
+}
+
+int
+sleepuntil(ulong tm)
+{
+	ulong now = time(0);
+	
+	if (now < tm)
+		return sleep((tm - now)*1000);
+	else
+		return 0;
+}
+
 void
 main(int argc, char *argv[])
 {
 	Job *j;
 	Tm tm;
 	Time t;
-	ulong now, last, nowsecs, future;
+	ulong now, last;		/* in seconds */
 	int i;
 
 	debug = 0;
@@ -107,14 +124,29 @@ main(int argc, char *argv[])
 
 	argv0 = "cron";
 	srand(getpid()*time(0));
-	last = time(0) / Minute;
+	last = time(0);
 	for(;;){
 		readalljobs();
-		now = time(0) / Minute;
-		if (now-last > Day/Minute)	/* don't go mad */
-			last = now - Day/Minute; /* just execute 1 day's jobs */
-		for(; last <= now; last++){
-			tm = *localtime(last*Minute);
+		/*
+		 * the system's notion of time may have jumped forward or
+		 * backward an arbitrary amount since the last call to time().
+		 */
+		now = time(0);
+		/*
+		 * if time has jumped backward, just note it and adapt.
+		 * if time has jumped forward more than a day,
+		 * just execute one day's jobs.
+		 */
+		if (now < last) {
+			syslog(0, CRONLOG, "time went backward");
+			last = now;
+		} else if (now - last > Day) {
+			syslog(0, CRONLOG, "time advanced more than a day");
+			last = now - Day;
+		}
+		now = minute(now);
+		for(last = minute(last); last <= now; last += Minute){
+			tm = *localtime(last);
 			t.min = 1ULL << tm.min;
 			t.hour = 1 << tm.hour;
 			t.wday = 1 << tm.wday;
@@ -130,13 +162,11 @@ main(int argc, char *argv[])
 						rexec(&users[i], j);
 		}
 		/*
-		 * if we're not there yet, sleep until (now+1)*Minute,
+		 * if we're not at next minute yet, sleep until a second past
+		 * (to allow for sleep intervals being approximate),
 		 * which synchronises with minute roll-over as a side-effect.
 		 */
-		future = (now + 1) * Minute;
-		nowsecs = time(0);
-		if (nowsecs < future)
-			sleep((future - nowsecs)*1000);
+		sleepuntil(now + Minute + 1);
 	}
 	/* not reached */
 }

+ 1 - 1
sys/src/cmd/auth/lib/mkfile

@@ -27,4 +27,4 @@ UPDATE=\
 	${OFILES:%.$O=%.c}\
 
 </sys/src/cmd/mksyslib
-CFLAGS=-w -I..
+CFLAGS=$CFLAGS -I..