Skip to content

Implement GH-10854: TSRM should set a smarter value for expected_threads #10867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2647,13 +2647,18 @@ PHPAPI void php_reserve_tsrm_memory(void)
}
/* }}} */

/* {{{ php_tsrm_startup */
PHPAPI bool php_tsrm_startup(void)
PHPAPI bool php_tsrm_startup_ex(int expected_threads)
{
bool ret = tsrm_startup(1, 1, 0, NULL);
bool ret = tsrm_startup(expected_threads, 1, 0, NULL);
php_reserve_tsrm_memory();
(void)ts_resource(0);
return ret;
}

/* {{{ php_tsrm_startup */
PHPAPI bool php_tsrm_startup(void)
{
return php_tsrm_startup_ex(1);
}
/* }}} */
#endif
1 change: 1 addition & 0 deletions main/php_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ extern int php_shutdown_environ(void);

#ifdef ZTS
PHPAPI void php_reserve_tsrm_memory(void);
PHPAPI bool php_tsrm_startup_ex(int expected_threads);
PHPAPI bool php_tsrm_startup(void);

#define PHP_ZTS 1
Expand Down
11 changes: 10 additions & 1 deletion sapi/apache2handler/sapi_apache2.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,16 @@ php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp
apache2_sapi_module.php_ini_path_override = apache2_php_ini_path_override;
}
#ifdef ZTS
php_tsrm_startup();
int expected_threads;
#ifdef AP_MPMQ_MAX_THREADS
if (ap_mpm_query(AP_MPMQ_MAX_THREADS, &expected_threads) != APR_SUCCESS) {
expected_threads = 1;
}
#else
expected_threads = 1;
#endif

php_tsrm_startup_ex(expected_threads);
# ifdef PHP_WIN32
ZEND_TSRMLS_CACHE_UPDATE();
# endif
Expand Down