diff --git a/core/emperor.c b/core/emperor.c index c004d09d..0a69dd34 100644 --- a/core/emperor.c +++ b/core/emperor.c @@ -1758,12 +1758,17 @@ static void emperor_cleanup() { void emperor_loop() { #if defined(__linux__) && defined(PR_SET_CHILD_SUBREAPER) - if (uwsgi.emperor_use_fork_server || uwsgi.emperor_subreaper) { + if (uwsgi.emperor_use_fork_server || uwsgi.emperor_subreaper || uwsgi.emperor_fork_server_attr) { if (prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0)) { uwsgi_error("uwsgi_fork_server()/fork()"); exit(1); } } +#else + if (uwsgi.emperor_use_fork_server || uwsgi.emperor_subreaper || uwsgi.emperor_fork_server_attr) { + uwsgi_log("*** DANGER: your kernel misses PR_SET_CHILD_SUBREAPER feature, required by the fork server ***\n"); + uwsgi_log("*** your Emperor will not be able to correctly wait() on vassals ***\n"); + } #endif // monitor a directory diff --git a/plugins/php/php_plugin.c b/plugins/php/php_plugin.c index bc15bad8..250c04af 100644 --- a/plugins/php/php_plugin.c +++ b/plugins/php/php_plugin.c @@ -4,6 +4,8 @@ extern struct uwsgi_server uwsgi; static sapi_module_struct uwsgi_sapi_module; +static int uwsgi_php_init(void); + struct uwsgi_php { struct uwsgi_string_list *allowed_docroot; struct uwsgi_string_list *allowed_ext; @@ -28,6 +30,8 @@ struct uwsgi_php { struct uwsgi_string_list *exec_after; char *sapi_name; + + int sapi_initialized; } uphp; void uwsgi_opt_php_ini(char *opt, char *value, void *foobar) { @@ -35,6 +39,10 @@ void uwsgi_opt_php_ini(char *opt, char *value, void *foobar) { uwsgi_sapi_module.php_ini_ignore = 1; } +void uwsgi_opt_early_php(char *opt, char *value, void *foobar) { + uwsgi_php_init(); +} + struct uwsgi_option uwsgi_php_options[] = { {"php-ini", required_argument, 0, "set php.ini path", uwsgi_opt_php_ini, NULL, 0}, @@ -61,6 +69,9 @@ struct uwsgi_option uwsgi_php_options[] = { {"php-exec-after", required_argument, 0, "run specified php code after the requested script", uwsgi_opt_add_string_list, &uphp.exec_after, 0}, {"php-exec-end", required_argument, 0, "run specified php code after the requested script", uwsgi_opt_add_string_list, &uphp.exec_after, 0}, {"php-sapi-name", required_argument, 0, "hack the sapi name (required for enabling zend opcode cache)", uwsgi_opt_set_str, &uphp.sapi_name, 0}, + + {"early-php", no_argument, 0, "initialize an early perl interpreter shared by all loaders", uwsgi_opt_early_php, NULL, UWSGI_OPT_IMMEDIATE}, + {"early-php-sapi-name", required_argument, 0, "hack the sapi name (required for enabling zend opcode cache)", uwsgi_opt_set_str, &uphp.sapi_name, UWSGI_OPT_IMMEDIATE}, UWSGI_END_OF_OPTIONS }; @@ -548,12 +559,15 @@ static sapi_module_struct uwsgi_sapi_module = { STANDARD_SAPI_MODULE_PROPERTIES }; -int uwsgi_php_init(void) { +static int uwsgi_php_init(void) { struct uwsgi_string_list *pset = uphp.set; struct uwsgi_string_list *append_config = uphp.append_config; - sapi_startup(&uwsgi_sapi_module); + if (!uphp.sapi_initialized) { + sapi_startup(&uwsgi_sapi_module); + uphp.sapi_initialized = 1; + } // applying custom options while(append_config) { @@ -584,6 +598,7 @@ int uwsgi_php_init(void) { if (uphp.sapi_name) { uwsgi_sapi_module.name = uphp.sapi_name; } + uwsgi_sapi_module.startup(&uwsgi_sapi_module); uwsgi_log("PHP %s initialized\n", PHP_VERSION);