diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 8bbdc5caabe5..41115b9fa86c 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -236,6 +236,9 @@ PHP 8.6 INTERNALS UPGRADE NOTES "INF" and "NAN" fail, while leading-numeric strings emit E_WARNING. When *failed is true, the returned value must not be used and an exception may already be pending. Passing an IS_UNDEF zval is a caller error. + . Added the zend_accel_restart_hook callback, which OPcache calls once a + scheduled restart has been carried out, on the thread that carried it out, + with the same reason as the zend_accel_schedule_restart_hook callback. ======================== 2. Build system changes diff --git a/Zend/zend.c b/Zend/zend.c index 3cfc0ffd2512..5b061a3a25ac 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -99,6 +99,7 @@ ZEND_API zend_string *(*zend_resolve_path)(zend_string *filename); ZEND_API zend_result (*zend_post_startup_cb)(void) = NULL; ZEND_API void (*zend_post_shutdown_cb)(void) = NULL; ZEND_API void (*zend_accel_schedule_restart_hook)(int reason) = NULL; +ZEND_API void (*zend_accel_restart_hook)(int reason) = NULL; ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result (*zend_random_bytes)(void *bytes, size_t size, char *errstr, size_t errstr_size) = NULL; ZEND_ATTRIBUTE_NONNULL ZEND_API void (*zend_random_bytes_insecure)(zend_random_bytes_insecure_state *state, void *bytes, size_t size) = NULL; diff --git a/Zend/zend.h b/Zend/zend.h index a0f094324426..1d93ebcc0f12 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -384,7 +384,10 @@ extern ZEND_ATTRIBUTE_NONNULL ZEND_API void (*zend_random_bytes_insecure)( extern ZEND_API zend_result (*zend_post_startup_cb)(void); extern ZEND_API void (*zend_post_shutdown_cb)(void); +/* Called by opcache when a restart is scheduled, with a zend_accel_restart_reason */ extern ZEND_API void (*zend_accel_schedule_restart_hook)(int reason); +/* Called by opcache once a scheduled restart has been carried out, with the same reason */ +extern ZEND_API void (*zend_accel_restart_hook)(int reason); ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3); ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3); diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 05fb6700ea72..b64c08c55702 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2970,6 +2970,10 @@ ZEND_RINIT_FUNCTION(zend_accelerator) ZCSG(last_restart_time)++; } accel_restart_leave(); + + if (UNEXPECTED(zend_accel_restart_hook)) { + zend_accel_restart_hook(ZCSG(restart_reason)); + } } } zend_shared_alloc_unlock();