mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Disable opcache if no SHM backend is available
Currently, configure fails when no SHM backend is available. Additionally, even after bypassing the configure check, opcache emits a fatal error if no SHM backend is available. Make the configure check non-fatal (a warning is printed). At runtime, disable opcache if no backend is available, in the same way we disable opcache by default on CLI. Closes GH-19350
This commit is contained in:
parent
fe88711b14
commit
e4078a6a70
4 changed files with 12 additions and 2 deletions
|
@ -3241,6 +3241,12 @@ static zend_result accel_post_startup(void)
|
||||||
accel_startup_ok = false;
|
accel_startup_ok = false;
|
||||||
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - probably not enough shared memory.");
|
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - probably not enough shared memory.");
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
case NO_SHM_BACKEND:
|
||||||
|
zend_accel_error(ACCEL_LOG_INFO, "Opcode Caching is disabled: No available SHM backend. Set opcache.enable=0 to hide this message.");
|
||||||
|
zps_startup_failure("No available SHM backend", NULL, accelerator_remove_cb);
|
||||||
|
/* Do not abort PHP startup */
|
||||||
|
return SUCCESS;
|
||||||
|
|
||||||
case SUCCESSFULLY_REATTACHED:
|
case SUCCESSFULLY_REATTACHED:
|
||||||
#ifdef HAVE_JIT
|
#ifdef HAVE_JIT
|
||||||
reattached = true;
|
reattached = true;
|
||||||
|
|
|
@ -346,9 +346,9 @@ PHP_ADD_EXTENSION_DEP(opcache, date)
|
||||||
PHP_ADD_EXTENSION_DEP(opcache, pcre)
|
PHP_ADD_EXTENSION_DEP(opcache, pcre)
|
||||||
|
|
||||||
if test "$php_cv_shm_ipc" != "yes" && test "$php_cv_shm_mmap_posix" != "yes" && test "$php_cv_shm_mmap_anon" != "yes"; then
|
if test "$php_cv_shm_ipc" != "yes" && test "$php_cv_shm_mmap_posix" != "yes" && test "$php_cv_shm_mmap_anon" != "yes"; then
|
||||||
AC_MSG_FAILURE(m4_text_wrap([
|
AC_MSG_WARN(m4_text_wrap([
|
||||||
No supported shared memory caching support was found when configuring
|
No supported shared memory caching support was found when configuring
|
||||||
opcache.
|
opcache. Opcache will be disabled.
|
||||||
]))
|
]))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -229,6 +229,9 @@ int zend_shared_alloc_startup(size_t requested_size, size_t reserved_size)
|
||||||
|
|
||||||
if (!g_shared_alloc_handler) {
|
if (!g_shared_alloc_handler) {
|
||||||
/* try memory handlers in order */
|
/* try memory handlers in order */
|
||||||
|
if (handler_table->name == NULL) {
|
||||||
|
return NO_SHM_BACKEND;
|
||||||
|
}
|
||||||
for (he = handler_table; he->name; he++) {
|
for (he = handler_table; he->name; he++) {
|
||||||
res = zend_shared_alloc_try(he, requested_size, &ZSMMG(shared_segments), &ZSMMG(shared_segments_count), &error_in);
|
res = zend_shared_alloc_try(he, requested_size, &ZSMMG(shared_segments), &ZSMMG(shared_segments_count), &error_in);
|
||||||
if (res) {
|
if (res) {
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
#define SUCCESSFULLY_REATTACHED 4
|
#define SUCCESSFULLY_REATTACHED 4
|
||||||
#define ALLOC_FAIL_MAPPING 8
|
#define ALLOC_FAIL_MAPPING 8
|
||||||
#define ALLOC_FALLBACK 9
|
#define ALLOC_FALLBACK 9
|
||||||
|
#define NO_SHM_BACKEND 10
|
||||||
|
|
||||||
typedef struct _zend_shared_segment {
|
typedef struct _zend_shared_segment {
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue