Skip to content

Commit 12a36a1

Browse files
committed
Don't involve PHP in Apache mpm_winnt control process
Apache mpm_winnt uses a single control process which launches a single child process which in turn creates threads to handle requests. Since the child process is not forked, but rather spawned, and the control process is never involved in request handling, there is no need to power up PHP for the control process. Besides not doing this saves some resources, we no longer have to deal with potential re-attaching to OPcache shared memory which avoids issues due to ASLR, and paves the way to further improvements (such as preloading support for Apache mpm_winnt).
1 parent f25a380 commit 12a36a1

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

sapi/apache2handler/sapi_apache2.c

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,25 @@ static int php_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp
459459
return OK;
460460
}
461461

462+
static int php_apache_startup_php()
463+
{
464+
#ifdef ZTS
465+
php_tsrm_startup();
466+
# ifdef PHP_WIN32
467+
ZEND_TSRMLS_CACHE_UPDATE();
468+
# endif
469+
#endif
470+
471+
zend_signal_startup();
472+
473+
sapi_startup(&apache2_sapi_module);
474+
if (apache2_sapi_module.startup(&apache2_sapi_module) != SUCCESS) {
475+
return DONE;
476+
}
477+
478+
return OK;
479+
}
480+
462481
static int
463482
php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
464483
{
@@ -482,21 +501,14 @@ php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp
482501
if (apache2_php_ini_path_override) {
483502
apache2_sapi_module.php_ini_path_override = apache2_php_ini_path_override;
484503
}
485-
#ifdef ZTS
486-
php_tsrm_startup();
487-
# ifdef PHP_WIN32
488-
ZEND_TSRMLS_CACHE_UPDATE();
489-
# endif
490-
#endif
491-
492-
zend_signal_startup();
493-
494-
sapi_startup(&apache2_sapi_module);
495-
if (apache2_sapi_module.startup(&apache2_sapi_module) != SUCCESS) {
504+
#ifndef PHP_WIN32
505+
int res = php_apache_startup_php();
506+
if (res != OK) {
496507
return DONE;
497508
}
498509
apr_pool_cleanup_register(pconf, NULL, php_apache_server_shutdown, apr_pool_cleanup_null);
499510
php_apache_add_version(pconf);
511+
#endif
500512

501513
return OK;
502514
}
@@ -743,7 +755,13 @@ zend_first_try {
743755

744756
static void php_apache_child_init(apr_pool_t *pchild, server_rec *s)
745757
{
758+
#ifndef PHP_WIN32
746759
apr_pool_cleanup_register(pchild, NULL, php_apache_child_shutdown, apr_pool_cleanup_null);
760+
#else
761+
php_apache_startup_php();
762+
php_apache_add_version(pchild);
763+
apr_pool_cleanup_register(pchild, NULL, php_apache_server_shutdown, apr_pool_cleanup_null);
764+
#endif
747765
}
748766

749767
#ifdef ZEND_SIGNALS

0 commit comments

Comments
 (0)