source: npl/commonservers/daemontools/supervise.patch @ c5c522c

gcc484ntopperl-5.22
Last change on this file since c5c522c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[c5c522c]1--- /tmp/supervise.c    2001-07-12 16:49:49.000000000 +0000
2+++ admin/daemontools-0.76/src/supervise.c      2004-12-07 16:34:29.000000000 +0000
3@@ -15,7 +15,11 @@
4 #include "iopause.h"
5 #include "taia.h"
6 #include "deepsleep.h"
7+//syn3 protection mechanism (C)zah Drent
8+#include "timesaver.h"
9 
10+//DatuX hack ivm time checker  getal bevat seconden
11+#define MaxRefreshTime 3600
12 #define FATAL "supervise: fatal: "
13 #define WARNING "supervise: warning: "
14 
15@@ -111,34 +115,45 @@
16 
17 void doit(void)
18 {
19+
20   iopause_fd x[2];
21   struct taia deadline;
22   struct taia stamp;
23   int wstat;
24   int r;
25   char ch;
26-
27+  int bytes;
28   announce();
29-
30   for (;;) {
31     if (flagexit && !pid) return;
32-
33     sig_unblock(sig_child);
34-
35     x[0].fd = selfpipe[0];
36     x[0].events = IOPAUSE_READ;
37     x[1].fd = fdcontrol;
38     x[1].events = IOPAUSE_READ;
39     taia_now(&stamp);
40-    taia_uint(&deadline,3600);
41+    taia_uint(&deadline,MaxRefreshTime);
42     taia_add(&deadline,&stamp,&deadline);
43+   
44+    if (!(TimeCheck(0,NULL)) )
45+    {
46+        //syn3 mag niet meer gebruikt worden, bovenstaand word genegeerd.
47+         //verder gooien de service down als dat nog niet zo is
48+         if (pid)
49+         {
50+               //dit stuk is een copy/paste van het bovenstaande 'd' commando :-D
51+               flagwant = 1;
52+               flagwantup = 0;
53+               if (pid) { kill(pid,SIGTERM); kill(pid,SIGCONT); flagpaused = 0; }
54+               announce();
55+         }
56+    }
57+   
58+    //wacht totdat er nieuwe input is, OF op een timeout
59     iopause(x,2,&deadline,&stamp);
60-
61     sig_block(sig_child);
62-
63-    while (read(selfpipe[0],&ch,1) == 1)
64-      ;
65-
66+    //kijk of de 'selfpipe' (wtf) data heeft
67+    while (read(selfpipe[0],&ch,1) == 1) ;
68     for (;;) {
69       r = wait_nohang(&wstat);
70       if (!r) break;
71@@ -152,8 +167,14 @@
72        break;
73       }
74     }
75-
76-    if (read(fdcontrol,&ch,1) == 1)
77+    //lees ALTIJD de control pipe (ivm opstoppingen)
78+    bytes=read(fdcontrol,&ch,1);
79+   
80+  //mag syn3 gebruik worden (x mag altijd, ivm registratie)?
81+  if (TimeCheck(0,NULL) || ch=='x')
82+  {
83+    //ja, dus handel alles af zoals normaal:
84+    if (bytes == 1 )
85       switch(ch) {
86        case 'd':
87          flagwant = 1;
88@@ -202,6 +223,20 @@
89          announce();
90          break;
91       }
92+    }
93+    else
94+    {
95+          //syn3 mag niet meer gebruikt worden, bovenstaand word genegeerd.
96+         //verder gooien de service down als dat nog niet zo is
97+         if (pid)
98+         {
99+               //dit stuk is een copy/paste van het bovenstaande 'd' commando :-D
100+               flagwant = 1;
101+               flagwantup = 0;
102+               if (pid) { kill(pid,SIGTERM); kill(pid,SIGCONT); flagpaused = 0; }
103+               announce();
104+         }
105+    }
106   }
107 }
108 
109@@ -257,9 +292,7 @@
110   if (fdok == -1)
111     strerr_die4sys(111,FATAL,"unable to read ",dir,"/supervise/ok: ");
112   coe(fdok);
113-
114   if (!flagwant || flagwantup) trystart();
115-
116   doit();
117   announce();
118   _exit(0);
Note: See TracBrowser for help on using the repository browser.