--- /tmp/supervise.c 2001-07-12 16:49:49.000000000 +0000 +++ admin/daemontools-0.76/src/supervise.c 2004-12-07 16:34:29.000000000 +0000 @@ -15,7 +15,11 @@ #include "iopause.h" #include "taia.h" #include "deepsleep.h" +//syn3 protection mechanism (C)zah Drent +#include "timesaver.h" +//DatuX hack ivm time checker getal bevat seconden +#define MaxRefreshTime 3600 #define FATAL "supervise: fatal: " #define WARNING "supervise: warning: " @@ -111,34 +115,45 @@ void doit(void) { + iopause_fd x[2]; struct taia deadline; struct taia stamp; int wstat; int r; char ch; - + int bytes; announce(); - for (;;) { if (flagexit && !pid) return; - sig_unblock(sig_child); - x[0].fd = selfpipe[0]; x[0].events = IOPAUSE_READ; x[1].fd = fdcontrol; x[1].events = IOPAUSE_READ; taia_now(&stamp); - taia_uint(&deadline,3600); + taia_uint(&deadline,MaxRefreshTime); taia_add(&deadline,&stamp,&deadline); + + if (!(TimeCheck(0,NULL)) ) + { + //syn3 mag niet meer gebruikt worden, bovenstaand word genegeerd. + //verder gooien de service down als dat nog niet zo is + if (pid) + { + //dit stuk is een copy/paste van het bovenstaande 'd' commando :-D + flagwant = 1; + flagwantup = 0; + if (pid) { kill(pid,SIGTERM); kill(pid,SIGCONT); flagpaused = 0; } + announce(); + } + } + + //wacht totdat er nieuwe input is, OF op een timeout iopause(x,2,&deadline,&stamp); - sig_block(sig_child); - - while (read(selfpipe[0],&ch,1) == 1) - ; - + //kijk of de 'selfpipe' (wtf) data heeft + while (read(selfpipe[0],&ch,1) == 1) ; for (;;) { r = wait_nohang(&wstat); if (!r) break; @@ -152,8 +167,14 @@ break; } } - - if (read(fdcontrol,&ch,1) == 1) + //lees ALTIJD de control pipe (ivm opstoppingen) + bytes=read(fdcontrol,&ch,1); + + //mag syn3 gebruik worden (x mag altijd, ivm registratie)? + if (TimeCheck(0,NULL) || ch=='x') + { + //ja, dus handel alles af zoals normaal: + if (bytes == 1 ) switch(ch) { case 'd': flagwant = 1; @@ -202,6 +223,20 @@ announce(); break; } + } + else + { + //syn3 mag niet meer gebruikt worden, bovenstaand word genegeerd. + //verder gooien de service down als dat nog niet zo is + if (pid) + { + //dit stuk is een copy/paste van het bovenstaande 'd' commando :-D + flagwant = 1; + flagwantup = 0; + if (pid) { kill(pid,SIGTERM); kill(pid,SIGCONT); flagpaused = 0; } + announce(); + } + } } } @@ -257,9 +292,7 @@ if (fdok == -1) strerr_die4sys(111,FATAL,"unable to read ",dir,"/supervise/ok: "); coe(fdok); - if (!flagwant || flagwantup) trystart(); - doit(); announce(); _exit(0);