@@ -466,7 +466,10 @@ public function store_result_get()
466
466
public function child_bucket_get ()
467
467
{
468
468
// this function does not apply to the parent
469
- if (self ::$ parent_pid == getmypid ()) return false ;
469
+ if (self ::$ parent_pid == getmypid ())
470
+ {
471
+ return false ;
472
+ }
470
473
471
474
return ($ this ->child_bucket );
472
475
}
@@ -479,7 +482,7 @@ public function child_bucket_get()
479
482
*/
480
483
public function add_bucket ($ bucket )
481
484
{
482
10000
td>
- /* create the bucket by copying values from the default bucket */
485
+ // create the bucket by copying values from the default bucket
483
486
$ this ->max_children [$ bucket ] = $ this ->max_children [self ::DEFAULT_BUCKET ];
484
487
$ this ->child_single_work_item [$ bucket ] = $ this ->child_single_work_item [self ::DEFAULT_BUCKET ];
485
488
$ this ->max_work_per_child [$ bucket ] = $ this ->max_work_per_child [self ::DEFAULT_BUCKET ];
@@ -507,7 +510,7 @@ public function add_bucket($bucket)
507
510
*/
508
511
public function register_child_run ($ function_name , $ bucket = self ::DEFAULT_BUCKET )
509
512
{
510
- /* call child function */
513
+ // call child function
511
514
if (is_callable ($ function_name ) || ( is_array ($ function_name ) && method_exists ($ function_name [0 ], $ function_name [1 ]) ) || method_exists ($ this , $ function_name ) || function_exists ($ function_name ) )
512
515
{
513
516
$ this ->child_function_run [$ bucket ] = $ function_name ;
@@ -538,7 +541,7 @@ public function register_parent_prefork($function_names)
538
541
*/
539
542
public function register_parent_fork ($ function_name , $ bucket = self ::DEFAULT_BUCKET )
540
543
{
541
- /* call child function */
544
+ // call child function
542
545
if ( is_callable ($ function_name ) || ( is_array ($ function_name ) && method_exists ($ function_name [0 ], $ function_name [1 ]) ) || method_exists ($ this , $ function_name ) || function_exists ($ function_name ) )
543
546
{
544
547
$ this ->parent_function_fork [$ bucket ] = $ function_name ;
@@ -558,7 +561,7 @@ public function register_parent_fork($function_name, $bucket = self::DEFAULT_BUC
558
561
*/
559
562
public function register_parent_sighup ($ function_name , $ cascade_signal = true )
560
563
{
561
- /* call child function */
564
+ // call child function
562
565
if ( is_callable ($ function_name ) || ( is_array ($ function_name ) && method_exists ($ function_name [0 ], $ function_name [1 ]) ) || method_exists ($ this , $ function_name ) || function_exists ($ function_name ) )
563
566
{
564
567
$ this ->parent_function_sighup = $ function_name ;
@@ -578,7 +581,7 @@ public function register_parent_sighup($function_name, $cascade_signal = true)
578
581
*/
579
582
public function register_child_sighup ($ function_name , $ bucket = self ::DEFAULT_BUCKET )
580
583
{
581
- /* call child function */
584
+ // call child function
582
585
if ( is_callable ($ function_name ) || ( is_array ($ function_name ) && method_exists ($ function_name [0 ], $ function_name [1 ]) ) || method_exists ($ this , $ function_name ) || function_exists ($ function_name ) )
583
586
{
584
587
$ this ->child_function_sighup [$ bucket ] = $ function_name ;
@@ -597,7 +600,7 @@ public function register_child_sighup($function_name, $bucket = self::DEFAULT_BU
597
600
*/
598
601
public function register_child_exit ($ function_name , $ bucket = self ::DEFAULT_BUCKET )
599
602
{
600
- /* call child function */
603
+ // call child function
601
604
if ( is_callable ($ function_name ) || ( is_array ($ function_name ) && method_exists ($ function_name [0 ], $ function_name [1 ]) ) || method_exists ($ this , $ function_name ) || function_exists ($ function_name ) )
602
605
{
603
606
$ this ->child_function_exit [$ bucket ] = $ function_name ;
@@ -616,7 +619,7 @@ public function register_child_exit($function_name, $bucket = self::DEFAULT_BUCK
616
619
*/
617
620
public function register_child_timeout ($ function_name , $ bucket = self ::DEFAULT_BUCKET )
618
621
{
619
- /* call child function */
622
+ // call child function
620
623
if ( is_callable ($ function_name ) || ( is_array ($ function_name ) && method_exists ($ function_name [0 ], $ function_name [1 ]) ) || method_exists ($ this , $ function_name ) || function_exists ($ function_name ) )
621
624
{
622
625
$ this ->child_function_timeout [$ bucket ] = $ function_name ;
@@ -653,7 +656,7 @@ public function register_parent_exit($function_name)
653
656
*/
654
657
public function register_parent_child_exit ($ function_name , $ bucket = self ::DEFAULT_BUCKET )
655
658
{
656
- /* call parent function */
659
+ // call parent function
657
660
if ( is_callable ($ function_name ) || ( is_array ($ function_name ) && method_exists ($ function_name [0 ], $ function_name [1 ]) ) || method_exists ($ this , $ function_name ) || function_exists ($ function_name ) )
658
661
{
659
662
$ this ->parent_function_child_exited [$ bucket ] = $ function_name ;
@@ -690,7 +693,7 @@ public function register_parent_results($function_name, $bucket = self::DEFAULT_
690
693
*/
691
694
public function register_logging ($ function_name , $ severity )
692
695
{
693
- /* call parent function */
696
+ // call parent function
694
697
if ( is_callable ($ function_name ) || ( is_array ($ function_name ) && method_exists ($ function_name [0 ], $ function_name [1 ]) ) || method_exists ($ this , $ function_name ) || function_exists ($ function_name ) )
695
698
{
696
699
$ this ->log_function [$ severity ] = $ function_name ;
@@ -708,10 +711,10 @@ public function register_logging($function_name, $severity)
708
711
*/
709
712
public function __construct ()
710
713
{
711
- /* record pid of parent process */
714
+ // record pid of parent process
712
715
self ::$ parent_pid = getmypid ();
713
716
714
- /* install signal handlers */
717
+ // install signal handlers
715
718
declare (ticks = 1 );
716
719
pcntl_signal (SIGHUP , array (&$ this , 'signal_handler_sighup ' ));
717
720
pcntl_signal (SIGCHLD , array (&$ this , 'signal_handler_sigchild ' ));
@@ -728,7 +731,7 @@ public function __construct()
728
731
pcntl_signal (SIGTRAP , SIG_IGN );
729
732
pcntl_signal (SIGSYS , SIG_IGN );
730
733
731
- /* add barracuda specific prefork functions (doesn't hurt anything) */
734
+ // add barracuda specific prefork functions (doesn't hurt anything)
732
735
$ this ->parent_function_prefork = array ('db_clear_connection_cache ' , 'memcache_clear_connection_cache ' );
733
736
}
734
737
@@ -770,12 +773,15 @@ public function signal_handler_sighup($signal_number)
770
773
else
771
774
{
772
775
// child received sighup. note a child is only in one bucket, do not loop through all buckets
773
- $ this ->log ('child process [ ' . getmypid () . '] received
9E7A
sighup with bucket type [ ' . $ this ->child_bucket . '] ' , self ::LOG_LEVEL_DEBUG );
774
- $ this ->invoke_callback (
775
- $ this ->child_function_sighup [$ this ->child_bucket ],
776
- array ($ this ->child_bucket ),
777
- true
778
- );
776
+ if (isset ($ this ->child_bucket ))
777
+ {
778
+ $ this ->log ('child process [ ' . getmypid () . '] received sighup with bucket type [ ' . $ this ->child_bucket . '] ' , self ::LOG_LEVEL_DEBUG );
779
+ $ this ->invoke_callback (
780
+ $ this ->child_function_sighup [$ this ->child_bucket ],
781
+ array ($ this ->child_bucket ),
782
+ true
783
+ );
784
+ }
779
785
}
780
786
}
781
787
@@ -911,7 +917,9 @@ public function signal_handler_sigint($signal_number)
911
917
{
912
918
// invoke child cleanup callback
913
919
if (isset ($ this ->child_bucket ))
920
+ {
914
921
$ this ->invoke_callback ($ this ->child_function_exit [$ this ->child_bucket ], $ parameters = array ($ this ->child_bucket ), true );
922
+ }
915
923
}
916
924
917
925
exit
378F
(-1 );
0 commit comments