Skip to content

Commit 025f603

Browse files
committed
Fixup
1 parent 21134fb commit 025f603

File tree

4 files changed

+11
-56
lines changed

4 files changed

+11
-56
lines changed

src/exception.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ impl PhpException {
6969

7070
/// Set the Zval object for the exception.
7171
///
72-
/// Exceptions can be based of instantiated Zval objects when you are throwing a custom exception with
73-
/// stateful properties.
72+
/// Exceptions can be based of instantiated Zval objects when you are
73+
/// throwing a custom exception with stateful properties.
7474
///
7575
/// # Parameters
7676
///

src/types/zval.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ impl Zval {
222222
}
223223
}
224224

225-
/// Returns a mutable reference to the zval if it is an internal indirect reference.
225+
/// Returns a mutable reference to the zval if it is an internal indirect
226+
/// reference.
226227
pub fn indirect_mut(&self) -> Option<&mut Zval> {
227228
if self.is_indirect() {
228229
Some(unsafe { &mut *(self.value.zv as *mut Zval) })

src/zend/globals.rs

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Types related to the PHP executor, sapi and process globals.
22
33
use std::collections::HashMap;
4+
use std::ffi::CStr;
45
use std::ops::{Deref, DerefMut};
56
use std::slice;
67
use std::str;
@@ -11,26 +12,21 @@ use crate::boxed::ZBox;
1112
#[cfg(php82)]
1213
use crate::ffi::zend_atomic_bool_store;
1314
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,
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

2323
use crate::types::{ZendHashTable, ZendObject, ZendStr};
2424

2525
use super::linked_list::ZendLinkedListIterator;
26-
use crate::types::{ZendHashTable, ZendObject};
2726

2827
/// Stores global variables used in the PHP executor.
2928
pub 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.
3531
pub 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-
194156
impl SapiModule {
195157
/// Returns a reference to the PHP SAPI module.
196158
///
@@ -556,12 +518,6 @@ static PROCESS_GLOBALS_LOCK: RwLock<()> = const_rwlock(());
556518
static SAPI_GLOBALS_LOCK: RwLock<()> = const_rwlock(());
557519
static 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

src/zend/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ mod ex;
77
mod function;
88
mod globals;
99
mod handlers;
10-
mod linked_list;
1110
mod ini_entry_def;
11+
mod linked_list;
1212
mod module;
1313
mod try_catch;
1414

@@ -27,12 +27,10 @@ pub use globals::ExecutorGlobals;
2727
pub use globals::FileGlobals;
2828
pub use globals::ProcessGlobals;
2929
pub use globals::SapiGlobals;
30-
pub use handlers::ZendObjectHandlers;
31-
pub use linked_list::ZendLinkedList;
32-
pub use globals::SapiGlobals;
3330
pub use globals::SapiModule;
3431
pub use handlers::ZendObjectHandlers;
3532
pub use ini_entry_def::IniEntryDef;
33+
pub use linked_list::ZendLinkedList;
3634
pub use module::ModuleEntry;
3735
#[cfg(feature = "embed")]
3836
pub(crate) use try_catch::panic_wrapper;

0 commit comments

Comments
 (0)