Skip to content

Commit aa02ce7

Browse files
Add OPcache restart hook
1 parent b9b317a commit aa02ce7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "zend_compile.h"
2727
#include "ZendAccelerator.h"
2828
#include "zend_persist.h"
29+
#include "zend_portability.h"
2930
#include "zend_shared_alloc.h"
3031
#include "zend_accelerator_module.h"
3132
#include "zend_accelerator_blacklist.h"
@@ -3410,6 +3411,8 @@ void accel_shutdown(void)
34103411
}
34113412
}
34123413

3414+
ZEND_EXT_API void (*zend_accel_schedule_restart_hook)(zend_accel_restart_reason reason);
3415+
34133416
void zend_accel_schedule_restart(zend_accel_restart_reason reason)
34143417
{
34153418
const char *zend_accel_restart_reason_text[ACCEL_RESTART_USER + 1] = {
@@ -3418,6 +3421,10 @@ void zend_accel_schedule_restart(zend_accel_restart_reason reason)
34183421
"user",
34193422
};
34203423

3424+
if (UNEXPECTED(zend_accel_schedule_restart_hook)) {
3425+
zend_accel_schedule_restart_hook(reason);
3426+
}
3427+
34213428
if (ZCSG(restart_pending)) {
34223429
/* don't schedule twice */
34233430
return;

ext/opcache/ZendAccelerator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,9 @@ 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);
316+
extern ZEND_EXT_API void (*zend_accel_schedule_restart_hook)(zend_accel_restart_reason reason);
316317
void zend_accel_schedule_restart(zend_accel_restart_reason reason);
317318
void zend_accel_schedule_restart_if_necessary(zend_accel_restart_reason reason);
318319
accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle, size_t *size);

0 commit comments

Comments
 (0)