|
@@ -230,13 +230,33 @@ int pyfcgi_wd_init(void (*wd_sig_cleaner)(int), const struct timespec *delay)
|
230
|
230
|
struct sigaction act;
|
231
|
231
|
struct sigevent sev;
|
232
|
232
|
pyfcgi_context_t *context;
|
|
233
|
+ struct timespec timeout;
|
|
234
|
+ double part, tmp;
|
233
|
235
|
int err;
|
234
|
236
|
|
235
|
237
|
context = &(PyFCGI_conf.context);
|
236
|
238
|
|
237
|
|
- PyFCGI_conf.context.wd_delay.tv_sec = delay->tv_sec;
|
238
|
|
- PyFCGI_conf.context.wd_delay.tv_nsec = delay->tv_nsec;
|
239
|
|
- pyfcgi_log(LOG_DEBUG, "Set watchdog with %ds timeout", PyFCGI_conf.context.wd_delay.tv_sec);
|
|
239
|
+ timeout = PyFCGI_conf.context.wd_delay = *delay;
|
|
240
|
+
|
|
241
|
+ //kill delay timeout
|
|
242
|
+ timeout.tv_nsec *= 1.5;
|
|
243
|
+ part = modf(((double)timeout.tv_sec/2.0), &tmp);
|
|
244
|
+ timeout.tv_nsec += part * 1000000000;
|
|
245
|
+ timeout.tv_sec = (time_t)(timeout.tv_sec * 1.5);
|
|
246
|
+ timeout.tv_sec += timeout.tv_nsec / 1000000000;
|
|
247
|
+ if(part != 0.0)
|
|
248
|
+ {
|
|
249
|
+ timeout.tv_nsec /= (long)(part * 1000000000);
|
|
250
|
+ }
|
|
251
|
+
|
|
252
|
+ PyFCGI_conf.context.wd_killdelay = timeout;
|
|
253
|
+
|
|
254
|
+ pyfcgi_log(LOG_DEBUG,
|
|
255
|
+ "Set watchdog with %d.%09ds timeout (%d.%09ds for SIGKILL)",
|
|
256
|
+ PyFCGI_conf.context.wd_delay.tv_sec,
|
|
257
|
+ PyFCGI_conf.context.wd_delay.tv_nsec,
|
|
258
|
+ PyFCGI_conf.context.wd_killdelay.tv_sec,
|
|
259
|
+ PyFCGI_conf.context.wd_killdelay.tv_nsec);
|
240
|
260
|
|
241
|
261
|
// Creating new timer with default sigevent (SIGEV_SIGNAL with SIGALRM)
|
242
|
262
|
if(timer_create(CLOCK_REALTIME, NULL, &(context->wd_timer)) < 0)
|
|
@@ -300,9 +320,8 @@ int pyfcgi_wd_arm()
|
300
|
320
|
strerror(err));
|
301
|
321
|
res = -1;
|
302
|
322
|
}
|
303
|
|
-
|
304
|
|
- timeout.it_value.tv_sec = (time_t)(timeout.it_value.tv_sec * 1.5);
|
305
|
|
- timeout.it_value.tv_nsec = 500000000;
|
|
323
|
+
|
|
324
|
+ timeout.it_value = context->wd_killdelay;
|
306
|
325
|
timeout.it_interval = timeout.it_value;
|
307
|
326
|
|
308
|
327
|
if(timer_settime(context->wd_timerkill, 0, &timeout, NULL) < 0)
|