Skip to content

Commit 4848a30

Browse files
committed
Disable opcache if no SHM backend is available
1 parent 659f55a commit 4848a30

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3273,6 +3273,12 @@ static zend_result accel_post_startup(void)
32733273
accel_startup_ok = false;
32743274
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - probably not enough shared memory.");
32753275
return SUCCESS;
3276+
case NO_SHM_BACKEND:
3277+
zend_accel_error(ACCEL_LOG_INFO, "Opcode Caching is disabled (No available SHM backend)");
3278+
zps_startup_failure("No available SHM backend", NULL, accelerator_remove_cb);
3279+
/* Do not abort PHP startup */
3280+
return SUCCESS;
3281+
32763282
case SUCCESSFULLY_REATTACHED:
32773283
#ifdef HAVE_JIT
32783284
reattached = true;

ext/opcache/zend_shared_alloc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ int zend_shared_alloc_startup(size_t requested_size, size_t reserved_size)
229229

230230
if (!g_shared_alloc_handler) {
231231
/* try memory handlers in order */
232+
if (handler_table->name == NULL) {
233+
return NO_SHM_BACKEND;
234+
}
232235
for (he = handler_table; he->name; he++) {
233236
res = zend_shared_alloc_try(he, requested_size, &ZSMMG(shared_segments), &ZSMMG(shared_segments_count), &error_in);
234237
if (res) {

ext/opcache/zend_shared_alloc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
#define SUCCESSFULLY_REATTACHED 4
7373
#define ALLOC_FAIL_MAPPING 8
7474
#define ALLOC_FALLBACK 9
75+
#define NO_SHM_BACKEND 10
7576

7677
typedef struct _zend_shared_segment {
7778
size_t size;

0 commit comments

Comments
 (0)