@@ -16,12 +16,11 @@ use crate::ffi::{
1616} ;
1717use crate :: types:: { ZendObject , Zval } ;
1818use crate :: zend:: { panic_wrapper, try_catch, ExecutorGlobals } ;
19- use parking_lot:: { const_rwlock , RwLock } ;
19+ use parking_lot:: { const_mutex , Mutex } ;
2020use std:: ffi:: { c_char, c_void, CString , NulError } ;
2121use std:: panic:: { resume_unwind, RefUnwindSafe } ;
2222use std:: path:: Path ;
2323use std:: ptr:: null_mut;
24-
2524pub use ffi:: ext_php_rs_sapi_startup;
2625pub use sapi:: SapiModule ;
2726
@@ -43,8 +42,6 @@ impl EmbedError {
4342 }
4443}
4544
46- static RUN_FN_LOCK : RwLock < ( ) > = const_rwlock ( ( ) ) ;
47-
4845impl Embed {
4946 /// Run a php script from a file
5047 ///
@@ -135,7 +132,11 @@ impl Embed {
135132 // This is to prevent multiple threads from running php at the same time
136133 // At some point we should detect if php is compiled with thread safety and
137134 // avoid doing that in this case
138- let _guard = RUN_FN_LOCK . write ( ) ;
135+ let _guard = {
136+ static RUN_FN_LOCK : Mutex < ( ) > = const_mutex ( ( ) ) ;
137+
138+ RUN_FN_LOCK . lock ( )
139+ } ;
139140
140141 let panic = unsafe {
141142 ext_php_rs_embed_callback (
@@ -206,6 +207,7 @@ impl Embed {
206207
207208#[ cfg( test) ]
208209mod tests {
210+ use crate :: ffi:: sapi_module;
209211 use super :: Embed ;
210212
211213 #[ test]
0 commit comments