|
@@ -610,6 +610,11 @@ static void worker_set_idle()
|
610
|
610
|
static void worker_set_busy()
|
611
|
611
|
{
|
612
|
612
|
int err;
|
|
613
|
+ short retry;
|
|
614
|
+ struct timespec timeout;
|
|
615
|
+ timeout.tv_sec = 0;
|
|
616
|
+ timeout.tv_nsec = 100000; //0.0001s
|
|
617
|
+
|
613
|
618
|
if(!_worker_idle) { return; }
|
614
|
619
|
/**@todo The pool handler WILL decrement the sem to figure if the pool
|
615
|
620
|
* is busy -__- Using sem_wait make sure that the worker will be able
|
|
@@ -618,18 +623,37 @@ static void worker_set_busy()
|
618
|
623
|
* maybe to nanosleep 0.01s and retry a sem_trywait... SysV sem are
|
619
|
624
|
* better T_T
|
620
|
625
|
*/
|
621
|
|
- if(sem_trywait(PyFCGI_SEM(SEM_WSTATE).sem) < 0)
|
|
626
|
+ err = 0;
|
|
627
|
+ retry = 10;
|
|
628
|
+ do
|
622
|
629
|
{
|
623
|
|
- err = errno;
|
624
|
|
- if(err == EAGAIN)
|
625
|
|
- { //panic
|
626
|
|
- pyfcgi_log(LOG_ALERT, "Unable to set busy ! WSTATE sem is allready 0 !!!");
|
627
|
|
- _worker_idle = 0;
|
628
|
|
- kill(PyFCGI_conf.context.ppid, SIGTERM);
|
629
|
|
- return;
|
|
630
|
+ err = 0;
|
|
631
|
+ if(sem_trywait(PyFCGI_SEM(SEM_WSTATE).sem) < 0)
|
|
632
|
+ {
|
|
633
|
+ err = errno;
|
|
634
|
+ if(err == EAGAIN)
|
|
635
|
+ {
|
|
636
|
+ nanosleep(&timeout, NULL);
|
|
637
|
+ err = 1;
|
|
638
|
+ }
|
|
639
|
+ else
|
|
640
|
+ {
|
|
641
|
+ pyfcgi_log(LOG_ERR,
|
|
642
|
+ "error decrementing the WSTATE semaphore : %s",
|
|
643
|
+ strerror(err));
|
|
644
|
+ kill(PyFCGI_conf.context.ppid, SIGTERM);
|
|
645
|
+ return;
|
|
646
|
+ }
|
630
|
647
|
}
|
631
|
|
- pyfcgi_log(LOG_ERR, "error decrementing the WSTATE semaphore : %s",
|
632
|
|
- strerror(err));
|
|
648
|
+ retry--;
|
|
649
|
+ }while(err & retry);
|
|
650
|
+ if(err)
|
|
651
|
+ {
|
|
652
|
+ pyfcgi_log(LOG_ALERT,
|
|
653
|
+ "Unable to set busy ! WSTATE sem is allready 0 !!!");
|
|
654
|
+ _worker_idle = 0;
|
|
655
|
+ kill(PyFCGI_conf.context.ppid, SIGTERM);
|
|
656
|
+ kill(PyFCGI_conf.context.pid, SIGTERM);
|
633
|
657
|
return;
|
634
|
658
|
}
|
635
|
659
|
_worker_idle = 0;
|