@@ -135,6 +135,7 @@ static struct ini_value_parser_s ini_fpm_pool_options[] = {
135135 { "pm.process_idle_timeout" , & fpm_conf_set_time , WPO (pm_process_idle_timeout ) },
136136 { "pm.max_requests" , & fpm_conf_set_integer , WPO (pm_max_requests ) },
137137 { "pm.status_path" , & fpm_conf_set_string , WPO (pm_status_path ) },
138+ { "pm.status_listen" , & fpm_conf_set_string , WPO (pm_status_listen ) },
138139 { "ping.path" , & fpm_conf_set_string , WPO (ping_path ) },
139140 { "ping.response" , & fpm_conf_set_string , WPO (ping_response ) },
140141 { "access.log" , & fpm_conf_set_string , WPO (access_log ) },
@@ -682,6 +683,57 @@ int fpm_worker_pool_config_free(struct fpm_worker_pool_config_s *wpc) /* {{{ */
682683}
683684/* }}} */
684685
686+ #define FPM_WPC_STR_CP_EX (_cfg , _scfg , _sf , _df ) \
687+ do { \
688+ if (_scfg->_df && !(_cfg->_sf = strdup(_scfg->_df))) { \
689+ return -1; \
690+ } \
691+ } while (0)
692+ #define FPM_WPC_STR_CP (_cfg , _scfg , _field ) FPM_WPC_STR_CP_EX(_cfg, _scfg, _field, _field)
693+
694+ static int fpm_worker_pool_shared_status_alloc (struct fpm_worker_pool_s * shared_wp ) { /* {{{ */
695+ struct fpm_worker_pool_config_s * config , * shared_config ;
696+ config = fpm_worker_pool_config_alloc ();
697+ if (!config ) {
698+ return -1 ;
699+ }
700+ shared_config = shared_wp -> config ;
701+
702+ config -> name = malloc (strlen (shared_config -> name ) + sizeof ("_status" ));
703+ if (!config -> name ) {
704+ return -1 ;
705+ }
706+ strcpy (config -> name , shared_config -> name );
707+ strcpy (config -> name + strlen (shared_config -> name ), "_status" );
708+
709+ if (!shared_config -> pm_status_path ) {
710+ shared_config -> pm_status_path = strdup ("/" );
711+ }
712+
713+ FPM_WPC_STR_CP_EX (config , shared_config , listen_address , pm_status_listen );
714+ #ifdef HAVE_FPM_ACL
715+ FPM_WPC_STR_CP (config , shared_config , listen_acl_groups );
716+ FPM_WPC_STR_CP (config , shared_config , listen_acl_users );
717+ #endif
718+ FPM_WPC_STR_CP (config , shared_config , listen_allowed_clients );
719+ FPM_WPC_STR_CP (config , shared_config , listen_group );
720+ FPM_WPC_STR_CP (config , shared_config , listen_owner );
721+ FPM_WPC_STR_CP (config , shared_config , listen_mode );
722+ FPM_WPC_STR_CP (config , shared_config , user );
723+ FPM_WPC_STR_CP (config , shared_config , group );
724+ FPM_WPC_STR_CP (config , shared_config , pm_status_path );
725+
726+ config -> pm = PM_STYLE_ONDEMAND ;
727+ config -> pm_max_children = 2 ;
728+ /* set to 1 to not warn about max children for shared pool */
729+ shared_wp -> warn_max_children = 1 ;
730+
731+ current_wp -> shared = shared_wp ;
732+
733+ return 0 ;
734+ }
735+ /* }}} */
736+
685737static int fpm_evaluate_full_path (char * * path , struct fpm_worker_pool_s * wp , char * default_prefix , int expand ) /* {{{ */
686738{
687739 char * prefix = NULL ;
@@ -856,6 +908,10 @@ static int fpm_conf_process_all_pools() /* {{{ */
856908 }
857909
858910 /* status */
911+ if (wp -> config -> pm_status_listen && fpm_worker_pool_shared_status_alloc (wp )) {
912+ zlog (ZLOG_ERROR , "[pool %s] failed to initialize a status listener pool" , wp -> config -> name );
913+ }
914+
859915 if (wp -> config -> pm_status_path && * wp -> config -> pm_status_path ) {
860916 size_t i ;
861917 char * status = wp -> config -> pm_status_path ;
@@ -865,7 +921,7 @@ static int fpm_conf_process_all_pools() /* {{{ */
865921 return -1 ;
866922 }
867923
868- if (strlen (status ) < 2 ) {
924+ if (! wp -> config -> pm_status_listen && ! wp -> shared && strlen (status ) < 2 ) {
869925 zlog (ZLOG_ERROR , "[pool %s] the status path '%s' is not long enough" , wp -> config -> name , status );
870926 return -1 ;
871927 }
@@ -1634,7 +1690,11 @@ static void fpm_conf_dump() /* {{{ */
16341690
16351691 for (wp = fpm_worker_all_pools ; wp ; wp = wp -> next ) {
16361692 struct key_value_s * kv ;
1637- if (!wp -> config ) continue ;
1693+
1694+ if (!wp -> config || wp -> shared ) {
1695+ continue ;
1696+ }
1697+
16381698 zlog (ZLOG_NOTICE , "[%s]" , STR2STR (wp -> config -> name ));
16391699 zlog (ZLOG_NOTICE , "\tprefix = %s" , STR2STR (wp -> config -> prefix ));
16401700 zlog (ZLOG_NOTICE , "\tuser = %s" , STR2STR (wp -> config -> user ));
@@ -1663,6 +1723,7 @@ static void fpm_conf_dump() /* {{{ */
16631723 zlog (ZLOG_NOTICE , "\tpm.process_idle_timeout = %d" , wp -> config -> pm_process_idle_timeout );
16641724 zlog (ZLOG_NOTICE , "\tpm.max_requests = %d" , wp -> config -> pm_max_requests );
16651725 zlog (ZLOG_NOTICE , "\tpm.status_path = %s" , STR2STR (wp -> config -> pm_status_path ));
1726+ zlog (ZLOG_NOTICE , "\tpm.status_listen = %s" , STR2STR (wp -> config -> pm_status_listen ));
16661727 zlog (ZLOG_NOTICE , "\tping.path = %s" , STR2STR (wp -> config -> ping_path ));
16671728 zlog (ZLOG_NOTICE , "\tping.response = %s" , STR2STR (wp -> config -> ping_response ));
16681729 zlog (ZLOG_NOTICE , "\taccess.log = %s" , STR2STR (wp -> config -> access_log ));
0 commit comments