11//! Types related to the PHP executor, sapi and process globals.
22
33use std:: collections:: HashMap ;
4+ use std:: ffi:: CStr ;
45use std:: ops:: { Deref , DerefMut } ;
56use std:: slice;
67use std:: str;
@@ -11,26 +12,21 @@ use crate::boxed::ZBox;
1112#[ cfg( php82) ]
1213use crate :: ffi:: zend_atomic_bool_store;
1314use crate :: ffi:: {
14- _zend_executor_globals, ext_php_rs_executor_globals, ext_php_rs_file_globals,
15- ext_php_rs_process_globals, ext_php_rs_sapi_globals, php_core_globals, php_file_globals,
16- sapi_globals_struct, sapi_header_struct, sapi_headers_struct, sapi_request_info,
15+ _sapi_module_struct, _zend_executor_globals, ext_php_rs_executor_globals,
16+ ext_php_rs_file_globals, ext_php_rs_process_globals, ext_php_rs_sapi_globals,
17+ ext_php_rs_sapi_module, php_core_globals, php_file_globals, sapi_globals_struct,
18+ sapi_header_struct, sapi_headers_struct, sapi_request_info, zend_ini_entry,
1719 zend_is_auto_global, TRACK_VARS_COOKIE , TRACK_VARS_ENV , TRACK_VARS_FILES , TRACK_VARS_GET ,
1820 TRACK_VARS_POST , TRACK_VARS_REQUEST , TRACK_VARS_SERVER ,
19- _sapi_globals_struct, _sapi_module_struct, _zend_executor_globals, ext_php_rs_executor_globals,
20- ext_php_rs_sapi_globals, ext_php_rs_sapi_module, zend_ini_entry,
2121} ;
2222
2323use crate :: types:: { ZendHashTable , ZendObject , ZendStr } ;
2424
2525use super :: linked_list:: ZendLinkedListIterator ;
26- use crate :: types:: { ZendHashTable , ZendObject } ;
2726
2827/// Stores global variables used in the PHP executor.
2928pub type ExecutorGlobals = _zend_executor_globals ;
3029
31- /// Stores global SAPI variables used in the PHP executor.
32- pub type SapiGlobals = _sapi_globals_struct ;
33-
3430/// Stores the SAPI module used in the PHP executor.
3531pub type SapiModule = _sapi_module_struct ;
3632
@@ -157,40 +153,6 @@ impl ExecutorGlobals {
157153 }
158154}
159155
160- impl SapiGlobals {
161- /// Returns a reference to the PHP SAPI globals.
162- ///
163- /// The executor globals are guarded by a RwLock. There can be multiple
164- /// immutable references at one time but only ever one mutable reference.
165- /// Attempting to retrieve the globals while already holding the global
166- /// guard will lead to a deadlock. Dropping the globals guard will release
167- /// the lock.
168- pub fn get ( ) -> GlobalReadGuard < Self > {
169- // SAFETY: PHP executor globals are statically declared therefore should never
170- // return an invalid pointer.
171- let globals = unsafe { ext_php_rs_sapi_globals ( ) . as_ref ( ) }
172- . expect ( "Static executor globals were invalid" ) ;
173- let guard = SAPI_LOCK . read ( ) ;
174- GlobalReadGuard { globals, guard }
175- }
176-
177- /// Returns a mutable reference to the PHP executor globals.
178- ///
179- /// The executor globals are guarded by a RwLock. There can be multiple
180- /// immutable references at one time but only ever one mutable reference.
181- /// Attempting to retrieve the globals while already holding the global
182- /// guard will lead to a deadlock. Dropping the globals guard will release
183- /// the lock.
184- pub fn get_mut ( ) -> GlobalWriteGuard < Self > {
185- // SAFETY: PHP executor globals are statically declared therefore should never
186- // return an invalid pointer.
187- let globals = unsafe { ext_php_rs_sapi_globals ( ) . as_mut ( ) }
188- . expect ( "Static executor globals were invalid" ) ;
189- let guard = SAPI_LOCK . write ( ) ;
190- GlobalWriteGuard { globals, guard }
191- }
192- }
193-
194156impl SapiModule {
195157 /// Returns a reference to the PHP SAPI module.
196158 ///
@@ -556,12 +518,6 @@ static PROCESS_GLOBALS_LOCK: RwLock<()> = const_rwlock(());
556518static SAPI_GLOBALS_LOCK : RwLock < ( ) > = const_rwlock ( ( ) ) ;
557519static FILE_GLOBALS_LOCK : RwLock < ( ) > = const_rwlock ( ( ) ) ;
558520
559- /// SAPI globals rwlock.
560- ///
561- /// PHP provides no indication if the executor globals are being accessed so
562- /// this is only effective on the Rust side.
563- static SAPI_LOCK : RwLock < ( ) > = const_rwlock ( ( ) ) ;
564-
565521/// SAPI globals rwlock.
566522///
567523/// PHP provides no indication if the executor globals are being accessed so
0 commit comments