Add OPcache restart hook (#15590)

This hook will allow observing extensions to observe the actual OPcache restart.
This commit is contained in:
Florian Engelhardt 2024-09-24 16:24:01 +02:00 committed by GitHub
parent c5b258fedc
commit 3293fafa27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 1 deletions

View file

@ -94,6 +94,7 @@ ZEND_API char *(*zend_getenv)(const char *name, size_t name_len);
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_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;

View file

@ -377,6 +377,8 @@ 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);
extern ZEND_API void (*zend_accel_schedule_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);
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn_unchecked(int type, const char *format, ...);

View file

@ -3431,6 +3431,11 @@ void zend_accel_schedule_restart(zend_accel_restart_reason reason)
/* don't schedule twice */
return;
}
if (UNEXPECTED(zend_accel_schedule_restart_hook)) {
zend_accel_schedule_restart_hook(reason);
}
zend_accel_error(ACCEL_LOG_DEBUG, "Restart Scheduled! Reason: %s",
zend_accel_restart_reason_text[reason]);

View file

@ -311,7 +311,7 @@ extern const char *zps_api_failure_reason;
BEGIN_EXTERN_C()
void accel_shutdown(void);
zend_result accel_activate(INIT_FUNC_ARGS);
zend_result accel_activate(INIT_FUNC_ARGS);
zend_result accel_post_deactivate(void);
void zend_accel_schedule_restart(zend_accel_restart_reason reason);
void zend_accel_schedule_restart_if_necessary(zend_accel_restart_reason reason);