Skip to content

Commit 84132eb

Browse files
committed
fix: add ext_php_rs_sapi_per_thread_shutdown
1 parent cf07741 commit 84132eb

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

src/embed/embed.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ SAPI_API void ext_php_rs_sapi_per_thread_init() {
4444
#endif
4545
}
4646

47+
SAPI_API void ext_php_rs_sapi_per_thread_shutdown() {
48+
#ifdef ZTS
49+
ts_free_thread();
50+
#endif
51+
}
52+
4753
void ext_php_rs_php_error(int type, const char *format, ...) {
4854
va_list args;
4955
va_start(args, format);

src/embed/embed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ void* ext_php_rs_embed_callback(int argc, char** argv, void* (*callback)(void *)
99
void ext_php_rs_sapi_startup();
1010
void ext_php_rs_sapi_shutdown();
1111
void ext_php_rs_sapi_per_thread_init();
12+
void ext_php_rs_sapi_per_thread_shutdown();
1213

1314
void ext_php_rs_php_error(int type, const char *format, ...);

src/embed/ffi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ unsafe extern "C" {
2020
pub fn ext_php_rs_sapi_startup();
2121
pub fn ext_php_rs_sapi_shutdown();
2222
pub fn ext_php_rs_sapi_per_thread_init();
23+
pub fn ext_php_rs_sapi_per_thread_shutdown();
2324

2425
pub fn ext_php_rs_php_error(
2526
type_: ::std::os::raw::c_int,

tests/sapi.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::ffi::c_char;
2020
use std::sync::Mutex;
2121

2222
#[cfg(php_zts)]
23-
use ext_php_rs::embed::ext_php_rs_sapi_per_thread_init;
23+
use ext_php_rs::embed::{ext_php_rs_sapi_per_thread_init, ext_php_rs_sapi_per_thread_shutdown};
2424
#[cfg(php_zts)]
2525
use std::sync::Arc;
2626
#[cfg(php_zts)]
@@ -178,6 +178,10 @@ fn test_sapi_multithread() {
178178
unsafe {
179179
php_request_shutdown(std::ptr::null_mut());
180180
}
181+
182+
unsafe {
183+
ext_php_rs_sapi_per_thread_shutdown();
184+
}
181185
});
182186

183187
handles.push(handle);

0 commit comments

Comments
 (0)