1
1
//! Types related to the PHP executor, sapi and process globals.
2
2
3
3
use std:: collections:: HashMap ;
4
+ use std:: ffi:: CStr ;
4
5
use std:: ops:: { Deref , DerefMut } ;
5
6
use std:: slice;
6
7
use std:: str;
@@ -11,26 +12,21 @@ use crate::boxed::ZBox;
11
12
#[ cfg( php82) ]
12
13
use crate :: ffi:: zend_atomic_bool_store;
13
14
use 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,
17
19
zend_is_auto_global, TRACK_VARS_COOKIE , TRACK_VARS_ENV , TRACK_VARS_FILES , TRACK_VARS_GET ,
18
20
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,
21
21
} ;
22
22
23
23
use crate :: types:: { ZendHashTable , ZendObject , ZendStr } ;
24
24
25
25
use super :: linked_list:: ZendLinkedListIterator ;
26
- use crate :: types:: { ZendHashTable , ZendObject } ;
27
26
28
27
/// Stores global variables used in the PHP executor.
29
28
pub type ExecutorGlobals = _zend_executor_globals ;
30
29
31
- /// Stores global SAPI variables used in the PHP executor.
32
- pub type SapiGlobals = _sapi_globals_struct ;
33
-
34
30
/// Stores the SAPI module used in the PHP executor.
35
31
pub type SapiModule = _sapi_module_struct ;
36
32
@@ -157,40 +153,6 @@ impl ExecutorGlobals {
157
153
}
158
154
}
159
155
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
-
194
156
impl SapiModule {
195
157
/// Returns a reference to the PHP SAPI module.
196
158
///
@@ -556,12 +518,6 @@ static PROCESS_GLOBALS_LOCK: RwLock<()> = const_rwlock(());
556
518
static SAPI_GLOBALS_LOCK : RwLock < ( ) > = const_rwlock ( ( ) ) ;
557
519
static FILE_GLOBALS_LOCK : RwLock < ( ) > = const_rwlock ( ( ) ) ;
558
520
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
-
565
521
/// SAPI globals rwlock.
566
522
///
567
523
/// PHP provides no indication if the executor globals are being accessed so
0 commit comments