Skip to content

opcache: Disallow changing opcache.memory_consumption when SHM is set up #19146

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ PHP NEWS
. Add support for CURLINFO_CONN_ID in curl_getinfo() (thecaliskan)
. Add support for CURLINFO_QUEUE_TIME_T in curl_getinfo() (thecaliskan)

- OPcache:
. Disallow changing opcache.memory_consumption when SHM is already set up.
(timwolla)

- Sockets:
. socket_set_option for multicast context throws a ValueError
when the socket family is not of AF_INET/AF_INET6 family. (David Carlier)
Expand Down
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,9 @@ PHP 8.5 UPGRADE NOTES
. The default value of opcache.jit_hot_loop is now 61 (a prime) to prevent it
from being a multiple of loop iteration counts.
It is recommended that this parameter is set to a prime number.
. Changing opcache.memory_consumption when OPcache SHM is already set up
will now correctly report a failure instead of silently doing nothing and
showing misleading values in PHPInfo.

- OpenSSL:
Added openssl.libctx to select the OpenSSL library context type. Either
Expand Down
2 changes: 2 additions & 0 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -3509,6 +3509,8 @@ void accel_shutdown(void)
if ((ini_entry = zend_hash_str_find_ptr(EG(ini_directives), "include_path", sizeof("include_path")-1)) != NULL) {
ini_entry->on_modify = orig_include_path_on_modify;
}

accel_startup_ok = false;
}

void zend_accel_schedule_restart(zend_accel_restart_reason reason)
Expand Down
9 changes: 9 additions & 0 deletions ext/opcache/zend_accelerator_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ static int validate_api_restriction(void)

static ZEND_INI_MH(OnUpdateMemoryConsumption)
{
if (accel_startup_ok) {
if (strcmp(sapi_module.name, "fpm-fcgi") == 0) {
zend_accel_error(ACCEL_LOG_WARNING, "opcache.memory_consumption cannot be changed when OPcache is already set up. Are you using php_admin_value[opcache.memory_consumption] in an individual pool's configuration?\n");
} else {
zend_accel_error(ACCEL_LOG_WARNING, "opcache.memory_consumption cannot be changed when OPcache is already set up.\n");
}
return FAILURE;
}

zend_long *p = (zend_long *) ZEND_INI_GET_ADDR();
zend_long memsize = atoi(ZSTR_VAL(new_value));
/* sanity check we must use at least 8 MB */
Expand Down