Skip to content

Commit b074ae1

Browse files
committed
fix(builders): module entries must switch globals ptr property by zts setting
1 parent e335c59 commit b074ae1

File tree

1 file changed

+57
-32
lines changed

1 file changed

+57
-32
lines changed

src/builders/module.rs

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -332,38 +332,63 @@ impl TryFrom<ModuleBuilder<'_>> for (ModuleEntry, ModuleStartup) {
332332
enums: builder.enums,
333333
};
334334

335-
Ok((
336-
ModuleEntry {
337-
size: mem::size_of::<ModuleEntry>().try_into()?,
338-
zend_api: ZEND_MODULE_API_NO,
339-
zend_debug: u8::from(PHP_DEBUG),
340-
zts: u8::from(PHP_ZTS),
341-
ini_entry: ptr::null(),
342-
deps: ptr::null(),
343-
name,
344-
functions,
345-
module_startup_func: builder.startup_func,
346-
module_shutdown_func: builder.shutdown_func,
347-
request_startup_func: builder.request_startup_func,
348-
request_shutdown_func: builder.request_shutdown_func,
349-
info_func: builder.info_func,
350-
version,
351-
globals_size: 0,
352-
#[cfg(not(php_zts))]
353-
globals_ptr: ptr::null_mut(),
354-
#[cfg(php_zts)]
355-
globals_id_ptr: ptr::null_mut(),
356-
globals_ctor: None,
357-
globals_dtor: None,
358-
post_deactivate_func: builder.post_deactivate_func,
359-
module_started: 0,
360-
type_: 0,
361-
handle: ptr::null_mut(),
362-
module_number: 0,
363-
build_id: unsafe { ext_php_rs_php_build_id() },
364-
},
365-
startup,
366-
))
335+
#[cfg(not(php_zts))]
336+
let module_entry = ModuleEntry {
337+
size: mem::size_of::<ModuleEntry>().try_into()?,
338+
zend_api: ZEND_MODULE_API_NO,
339+
zend_debug: u8::from(PHP_DEBUG),
340+
zts: u8::from(PHP_ZTS),
341+
ini_entry: ptr::null(),
342+
deps: ptr::null(),
343+
name,
344+
functions,
345+
module_startup_func: builder.startup_func,
346+
module_shutdown_func: builder.shutdown_func,
347+
request_startup_func: builder.request_startup_func,
348+
request_shutdown_func: builder.request_shutdown_func,
349+
info_func: builder.info_func,
350+
version,
351+
globals_size: 0,
352+
globals_ptr: ptr::null_mut(),
353+
globals_ctor: None,
354+
globals_dtor: None,
355+
post_deactivate_func: builder.post_deactivate_func,
356+
module_started: 0,
357+
type_: 0,
358+
handle: ptr::null_mut(),
359+
module_number: 0,
360+
build_id: unsafe { ext_php_rs_php_build_id() },
361+
};
362+
363+
#[cfg(php_zts)]
364+
let module_entry = ModuleEntry {
365+
size: mem::size_of::<ModuleEntry>().try_into()?,
366+
zend_api: ZEND_MODULE_API_NO,
367+
zend_debug: u8::from(PHP_DEBUG),
368+
zts: u8::from(PHP_ZTS),
369+
ini_entry: ptr::null(),
370+
deps: ptr::null(),
371+
name,
372+
functions,
373+
module_startup_func: builder.startup_func,
374+
module_shutdown_func: builder.shutdown_func,
375+
request_startup_func: builder.request_startup_func,
376+
request_shutdown_func: builder.request_shutdown_func,
377+
info_func: builder.info_func,
378+
version,
379+
globals_size: 0,
380+
globals_id_ptr: ptr::null_mut(),
381+
globals_ctor: None,
382+
globals_dtor: None,
383+
post_deactivate_func: builder.post_deactivate_func,
384+
module_started: 0,
385+
type_: 0,
386+
handle: ptr::null_mut(),
387+
module_number: 0,
388+
build_id: unsafe { ext_php_rs_php_build_id() },
389+
};
390+
391+
Ok((module_entry, startup))
367392
}
368393
}
369394

0 commit comments

Comments
 (0)