Skip to content

Commit 3293faf

Browse files
Add OPcache restart hook (#15590)
This hook will allow observing extensions to observe the actual OPcache restart.
1 parent c5b258f commit 3293faf

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

Zend/zend.c

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ ZEND_API char *(*zend_getenv)(const char *name, size_t name_len);
9494
ZEND_API zend_string *(*zend_resolve_path)(zend_string *filename);
9595
ZEND_API zend_result (*zend_post_startup_cb)(void) = NULL;
9696
ZEND_API void (*zend_post_shutdown_cb)(void) = NULL;
97+
ZEND_API void (*zend_accel_schedule_restart_hook)(int reason) = NULL;
9798
ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result (*zend_random_bytes)(void *bytes, size_t size, char *errstr, size_t errstr_size) = NULL;
9899
ZEND_ATTRIBUTE_NONNULL ZEND_API void (*zend_random_bytes_insecure)(zend_random_bytes_insecure_state *state, void *bytes, size_t size) = NULL;
99100

Zend/zend.h

+2
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ extern ZEND_ATTRIBUTE_NONNULL ZEND_API void (*zend_random_bytes_insecure)(
377377
extern ZEND_API zend_result (*zend_post_startup_cb)(void);
378378
extern ZEND_API void (*zend_post_shutdown_cb)(void);
379379

380+
extern ZEND_API void (*zend_accel_schedule_restart_hook)(int reason);
381+
380382
ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
381383
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
382384
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn_unchecked(int type, const char *format, ...);

ext/opcache/ZendAccelerator.c

+5
Original file line numberDiff line numberDiff line change
@@ -3431,6 +3431,11 @@ void zend_accel_schedule_restart(zend_accel_restart_reason reason)
34313431
/* don't schedule twice */
34323432
return;
34333433
}
3434+
3435+
if (UNEXPECTED(zend_accel_schedule_restart_hook)) {
3436+
zend_accel_schedule_restart_hook(reason);
3437+
}
3438+
34343439
zend_accel_error(ACCEL_LOG_DEBUG, "Restart Scheduled! Reason: %s",
34353440
zend_accel_restart_reason_text[reason]);
34363441

ext/opcache/ZendAccelerator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ extern const char *zps_api_failure_reason;
311311
BEGIN_EXTERN_C()
312312

313313
void accel_shutdown(void);
314-
zend_result accel_activate(INIT_FUNC_ARGS);
314+
zend_result accel_activate(INIT_FUNC_ARGS);
315315
zend_result accel_post_deactivate(void);
316316
void zend_accel_schedule_restart(zend_accel_restart_reason reason);
317317
void zend_accel_schedule_restart_if_necessary(zend_accel_restart_reason reason);

0 commit comments

Comments
 (0)