@@ -7,12 +7,14 @@ use std::str;
77use parking_lot:: { const_rwlock, RwLock , RwLockReadGuard , RwLockWriteGuard } ;
88
99use crate :: boxed:: ZBox ;
10+ #[ cfg( php82) ]
11+ use crate :: ffi:: zend_atomic_bool_store;
1012use crate :: ffi:: {
11- _zend_executor_globals, ext_php_rs_executor_globals, ext_php_rs_process_globals ,
12- ext_php_rs_sapi_globals , file_globals , php_core_globals, php_file_globals, sapi_globals_struct ,
13- sapi_header_struct, sapi_headers_struct, sapi_request_info, zend_is_auto_global ,
14- TRACK_VARS_COOKIE , TRACK_VARS_ENV , TRACK_VARS_FILES , TRACK_VARS_GET , TRACK_VARS_POST ,
15- TRACK_VARS_REQUEST , TRACK_VARS_SERVER ,
13+ _zend_executor_globals, ext_php_rs_executor_globals, ext_php_rs_file_globals ,
14+ ext_php_rs_process_globals , ext_php_rs_sapi_globals , php_core_globals, php_file_globals,
15+ sapi_globals_struct , sapi_header_struct, sapi_headers_struct, sapi_request_info,
16+ zend_is_auto_global , TRACK_VARS_COOKIE , TRACK_VARS_ENV , TRACK_VARS_FILES , TRACK_VARS_GET ,
17+ TRACK_VARS_POST , TRACK_VARS_REQUEST , TRACK_VARS_SERVER ,
1618} ;
1719
1820use crate :: types:: { ZendHashTable , ZendObject , ZendStr } ;
@@ -80,6 +82,21 @@ impl ExecutorGlobals {
8082 // SAFETY: `as_mut` checks for null.
8183 Some ( unsafe { ZBox :: from_raw ( exception_ptr. as_mut ( ) ?) } )
8284 }
85+
86+ /// Request an interrupt of the PHP VM. This will call the registered
87+ /// interrupt handler function.
88+ /// set with [`crate::ffi::zend_interrupt_function`].
89+ pub fn request_interrupt ( & mut self ) {
90+ cfg_if:: cfg_if! {
91+ if #[ cfg( php82) ] {
92+ unsafe {
93+ zend_atomic_bool_store( & mut self . vm_interrupt, true ) ;
94+ }
95+ } else {
96+ self . vm_interrupt = true ;
97+ }
98+ }
99+ }
83100}
84101
85102/// Stores global variables used in the PHP executor.
@@ -378,7 +395,8 @@ impl FileGlobals {
378395 pub fn get ( ) -> GlobalReadGuard < Self > {
379396 // SAFETY: PHP executor globals are statically declared therefore should never
380397 // return an invalid pointer.
381- let globals = unsafe { & file_globals } ;
398+ let globals = unsafe { ext_php_rs_file_globals ( ) . as_ref ( ) }
399+ . expect ( "Static file globals were invalid" ) ;
382400 let guard = FILE_GLOBALS_LOCK . read ( ) ;
383401 GlobalReadGuard { globals, guard }
384402 }
@@ -393,7 +411,7 @@ impl FileGlobals {
393411 pub fn get_mut ( ) -> GlobalWriteGuard < Self > {
394412 // SAFETY: PHP executor globals are statically declared therefore should never
395413 // return an invalid pointer.
396- let globals = unsafe { & mut file_globals } ;
414+ let globals = unsafe { & mut * ext_php_rs_file_globals ( ) } ;
397415 let guard = SAPI_GLOBALS_LOCK . write ( ) ;
398416 GlobalWriteGuard { globals, guard }
399417 }
0 commit comments