mirror of
https://github.com/php/frankenphp.git
synced 2026-03-24 00:52:11 +01:00
feat: Adds automatic thread scaling at runtime and php_ini configuration in Caddyfile (#1266)
Adds option to scale threads at runtime Adds php_ini configuration in Caddyfile
This commit is contained in:
25
frankenphp.c
25
frankenphp.c
@@ -78,7 +78,7 @@ typedef struct frankenphp_server_context {
|
||||
bool finished;
|
||||
} frankenphp_server_context;
|
||||
|
||||
__thread bool should_filter_var = 0;
|
||||
bool should_filter_var = 0;
|
||||
__thread frankenphp_server_context *local_ctx = NULL;
|
||||
__thread uintptr_t thread_index;
|
||||
__thread zval *os_environment = NULL;
|
||||
@@ -767,7 +767,8 @@ frankenphp_register_variable_from_request_info(zend_string *zKey, char *value,
|
||||
frankenphp_register_trusted_var(zKey, value, strlen(value),
|
||||
Z_ARRVAL_P(track_vars_array));
|
||||
} else if (must_be_present) {
|
||||
frankenphp_register_trusted_var(zKey, "", 0, Z_ARRVAL_P(track_vars_array));
|
||||
frankenphp_register_trusted_var(zKey, NULL, 0,
|
||||
Z_ARRVAL_P(track_vars_array));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -913,12 +914,6 @@ static void *php_thread(void *arg) {
|
||||
|
||||
local_ctx = malloc(sizeof(frankenphp_server_context));
|
||||
|
||||
/* check if a default filter is set in php.ini and only filter if
|
||||
* it is, this is deprecated and will be removed in PHP 9 */
|
||||
char *default_filter;
|
||||
cfg_get_string("filter.default", &default_filter);
|
||||
should_filter_var = default_filter != NULL;
|
||||
|
||||
// loop until Go signals to stop
|
||||
char *scriptName = NULL;
|
||||
while ((scriptName = go_frankenphp_before_script_execution(thread_index))) {
|
||||
@@ -980,10 +975,22 @@ static void *php_main(void *arg) {
|
||||
memcpy(frankenphp_sapi_module.ini_entries, HARDCODED_INI,
|
||||
sizeof(HARDCODED_INI));
|
||||
#endif
|
||||
#else
|
||||
/* overwrite php.ini with custom user settings */
|
||||
char *php_ini_overrides = go_get_custom_php_ini();
|
||||
if (php_ini_overrides != NULL) {
|
||||
frankenphp_sapi_module.ini_entries = php_ini_overrides;
|
||||
}
|
||||
#endif
|
||||
|
||||
frankenphp_sapi_module.startup(&frankenphp_sapi_module);
|
||||
|
||||
/* check if a default filter is set in php.ini and only filter if
|
||||
* it is, this is deprecated and will be removed in PHP 9 */
|
||||
char *default_filter;
|
||||
cfg_get_string("filter.default", &default_filter);
|
||||
should_filter_var = default_filter != NULL;
|
||||
|
||||
go_frankenphp_main_thread_is_ready();
|
||||
|
||||
/* channel closed, shutdown gracefully */
|
||||
@@ -1252,3 +1259,5 @@ int frankenphp_reset_opcache(void) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int frankenphp_get_current_memory_limit() { return PG(memory_limit); }
|
||||
|
||||
Reference in New Issue
Block a user