|
@@ -22,6 +22,10 @@
|
22
|
22
|
* @ingroup work_master_proc */
|
23
|
23
|
static void clean_exit(int status)
|
24
|
24
|
{
|
|
25
|
+ if(PyFCGI_conf.context.n_wrk)
|
|
26
|
+ {
|
|
27
|
+ kill(PyFCGI_conf.context.pid, SIGTERM);
|
|
28
|
+ }
|
25
|
29
|
pyfcgi_IPC_close(IPC_WSTATE | IPC_WREQS | IPC_SEMST | IPC_SHMST);
|
26
|
30
|
pyfcgi_IPC_destroy(IPC_WSTATE | IPC_WREQS | IPC_SEMST | IPC_SHMST);
|
27
|
31
|
exit(status);
|
|
@@ -166,6 +170,8 @@ int responder_loop()
|
166
|
170
|
PyFCGI_conf.context.n_wrk = n_wrk;
|
167
|
171
|
if(last_update != (now = time(NULL)))
|
168
|
172
|
{
|
|
173
|
+pyfcgi_log(LOG_DEBUG, "Infos : n_wrk=%d max=%d min=%d",
|
|
174
|
+ n_wrk, PyFCGI_conf.max_wrk, PyFCGI_conf.min_wrk);
|
169
|
175
|
pyfcgi_pool_shm_update(n_wrk);
|
170
|
176
|
last_update = now;
|
171
|
177
|
}
|
|
@@ -191,11 +197,19 @@ int responder_loop()
|
191
|
197
|
}
|
192
|
198
|
if(WIFSIGNALED(status))
|
193
|
199
|
{
|
|
200
|
+ if(WTERMSIG(status) == 9)
|
|
201
|
+ {
|
|
202
|
+ pyfcgi_log(LOG_ALERT,
|
|
203
|
+ "Worker[%d] get killed ! No guaranty that SEM_WSTATE is OK, exiting...",
|
|
204
|
+ n);
|
|
205
|
+ clean_exit(PYFCGI_WORKER_FAIL);
|
|
206
|
+ }
|
194
|
207
|
if(WTERMSIG(status) == 11)
|
195
|
208
|
{
|
196
|
209
|
pyfcgi_log(LOG_ALERT,
|
197
|
|
- "Worker[%d] segfault !",
|
|
210
|
+ "Worker[%d] segfault ! No guaranty that SEM_WSTATE is OK, exiting...",
|
198
|
211
|
n);
|
|
212
|
+ clean_exit(PYFCGI_WORKER_FAIL);
|
199
|
213
|
}
|
200
|
214
|
else
|
201
|
215
|
{
|
|
@@ -442,7 +456,13 @@ int pyfcgi_pool_idle(const struct timespec *timeout)
|
442
|
456
|
clean_exit(PYFCGI_FATAL);
|
443
|
457
|
}
|
444
|
458
|
}
|
445
|
|
- sem_post(PyFCGI_SEM(SEM_WSTATE).sem); //Hope no worker fails to set busy...
|
|
459
|
+ if(sem_post(PyFCGI_SEM(SEM_WSTATE).sem) < 0)
|
|
460
|
+ {
|
|
461
|
+ pyfcgi_log(LOG_ALERT,
|
|
462
|
+ "Unable to sempost after a sem_timedwait : %s",
|
|
463
|
+ strerror(errno));
|
|
464
|
+ clean_exit(PYFCGI_FATAL);
|
|
465
|
+ }
|
446
|
466
|
return 1; //idle
|
447
|
467
|
}
|
448
|
468
|
|
|
@@ -493,6 +513,7 @@ void pool_sighandler(int signum)
|
493
|
513
|
}
|
494
|
514
|
|
495
|
515
|
}
|
|
516
|
+ PyFCGI_conf.context.n_wrk = 0;
|
496
|
517
|
clean_exit(0);
|
497
|
518
|
}
|
498
|
519
|
|
|
@@ -553,9 +574,14 @@ void pyfcgi_pool_shm_update(int nworker)
|
553
|
574
|
|
554
|
575
|
data = (pyfcgi_stats_shm_t*)PyFCGI_conf.shm.ptr;
|
555
|
576
|
data->nworker = nworker;
|
|
577
|
+ err = 0;
|
556
|
578
|
if(sem_getvalue(PyFCGI_SEM(SEM_WSTATE).sem, &(data->pool_load)) < 0)
|
557
|
579
|
{
|
558
|
580
|
data->pool_load = -1;
|
|
581
|
+ pyfcgi_log(LOG_ALERT,
|
|
582
|
+ "Unable to get semaphore value for SEM_WSTATE : ",
|
|
583
|
+ strerror(errno));
|
|
584
|
+ err = 1;
|
559
|
585
|
}
|
560
|
586
|
|
561
|
587
|
if(sem_post(PyFCGI_SEM(SEM_STATS).sem) < 0)
|
|
@@ -564,5 +590,9 @@ void pyfcgi_pool_shm_update(int nworker)
|
564
|
590
|
strerror(errno));
|
565
|
591
|
clean_exit(PYFCGI_FATAL);
|
566
|
592
|
}
|
|
593
|
+ if(err)
|
|
594
|
+ {
|
|
595
|
+ clean_exit(PYFCGI_FATAL);
|
|
596
|
+ }
|
567
|
597
|
}
|
568
|
598
|
|