File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ use std::{
3535/// Because PHP is single threaded, so there is no lock here.
3636static mut GLOBAL_MODULE : * mut Module = null_mut ( ) ;
3737
38+ static mut GLOBAL_MODULE_ENTRY : * mut zend_module_entry = null_mut ( ) ;
39+
3840unsafe extern "C" fn module_startup ( _type : c_int , module_number : c_int ) -> c_int {
3941 let module = GLOBAL_MODULE . as_mut ( ) . unwrap ( ) ;
4042
@@ -211,6 +213,10 @@ impl Module {
211213 /// Leak memory to generate `zend_module_entry` pointer.
212214 #[ doc( hidden) ]
213215 pub unsafe fn module_entry ( self ) -> * const zend_module_entry {
216+ if !GLOBAL_MODULE_ENTRY . is_null ( ) {
217+ return GLOBAL_MODULE_ENTRY ;
218+ }
219+
214220 assert ! ( !self . name. as_bytes( ) . is_empty( ) , "module name must be set" ) ;
215221 assert ! (
216222 !self . version. as_bytes( ) . is_empty( ) ,
@@ -249,10 +255,10 @@ impl Module {
249255 build_id : phper_get_zend_module_build_id ( ) ,
250256 } ) ;
251257
252- assert ! ( GLOBAL_MODULE . is_null( ) , "GLOBAL_MODULE has registered" ) ;
253258 GLOBAL_MODULE = Box :: into_raw ( module) ;
259+ GLOBAL_MODULE_ENTRY = Box :: into_raw ( entry) ;
254260
255- Box :: into_raw ( entry )
261+ GLOBAL_MODULE_ENTRY
256262 }
257263
258264 fn function_entries ( & self ) -> * const zend_function_entry {
You can’t perform that action at this time.
0 commit comments