source:
npl/commonservers/daemontools/supervise.patch
@
c5c522c
Last change on this file since c5c522c was c5c522c, checked in by , 8 years ago | |
---|---|
|
|
File size: 2.7 KB |
-
supervise.c
old new 15 15 #include "iopause.h" 16 16 #include "taia.h" 17 17 #include "deepsleep.h" 18 //syn3 protection mechanism (C)zah Drent 19 #include "timesaver.h" 18 20 21 //DatuX hack ivm time checker getal bevat seconden 22 #define MaxRefreshTime 3600 19 23 #define FATAL "supervise: fatal: " 20 24 #define WARNING "supervise: warning: " 21 25 … … 111 115 112 116 void doit(void) 113 117 { 118 114 119 iopause_fd x[2]; 115 120 struct taia deadline; 116 121 struct taia stamp; 117 122 int wstat; 118 123 int r; 119 124 char ch; 120 125 int bytes; 121 126 announce(); 122 123 127 for (;;) { 124 128 if (flagexit && !pid) return; 125 126 129 sig_unblock(sig_child); 127 128 130 x[0].fd = selfpipe[0]; 129 131 x[0].events = IOPAUSE_READ; 130 132 x[1].fd = fdcontrol; 131 133 x[1].events = IOPAUSE_READ; 132 134 taia_now(&stamp); 133 taia_uint(&deadline, 3600);135 taia_uint(&deadline,MaxRefreshTime); 134 136 taia_add(&deadline,&stamp,&deadline); 137 138 if (!(TimeCheck(0,NULL)) ) 139 { 140 //syn3 mag niet meer gebruikt worden, bovenstaand word genegeerd. 141 //verder gooien de service down als dat nog niet zo is 142 if (pid) 143 { 144 //dit stuk is een copy/paste van het bovenstaande 'd' commando :-D 145 flagwant = 1; 146 flagwantup = 0; 147 if (pid) { kill(pid,SIGTERM); kill(pid,SIGCONT); flagpaused = 0; } 148 announce(); 149 } 150 } 151 152 //wacht totdat er nieuwe input is, OF op een timeout 135 153 iopause(x,2,&deadline,&stamp); 136 137 154 sig_block(sig_child); 138 139 while (read(selfpipe[0],&ch,1) == 1) 140 ; 141 155 //kijk of de 'selfpipe' (wtf) data heeft 156 while (read(selfpipe[0],&ch,1) == 1) ; 142 157 for (;;) { 143 158 r = wait_nohang(&wstat); 144 159 if (!r) break; … … 152 167 break; 153 168 } 154 169 } 155 156 if (read(fdcontrol,&ch,1) == 1) 170 //lees ALTIJD de control pipe (ivm opstoppingen) 171 bytes=read(fdcontrol,&ch,1); 172 173 //mag syn3 gebruik worden (x mag altijd, ivm registratie)? 174 if (TimeCheck(0,NULL) || ch=='x') 175 { 176 //ja, dus handel alles af zoals normaal: 177 if (bytes == 1 ) 157 178 switch(ch) { 158 179 case 'd': 159 180 flagwant = 1; … … 202 223 announce(); 203 224 break; 204 225 } 226 } 227 else 228 { 229 //syn3 mag niet meer gebruikt worden, bovenstaand word genegeerd. 230 //verder gooien de service down als dat nog niet zo is 231 if (pid) 232 { 233 //dit stuk is een copy/paste van het bovenstaande 'd' commando :-D 234 flagwant = 1; 235 flagwantup = 0; 236 if (pid) { kill(pid,SIGTERM); kill(pid,SIGCONT); flagpaused = 0; } 237 announce(); 238 } 239 } 205 240 } 206 241 } 207 242 … … 257 292 if (fdok == -1) 258 293 strerr_die4sys(111,FATAL,"unable to read ",dir,"/supervise/ok: "); 259 294 coe(fdok); 260 261 295 if (!flagwant || flagwantup) trystart(); 262 263 296 doit(); 264 297 announce(); 265 298 _exit(0);
Note: See TracBrowser
for help on using the repository browser.