@@ -49,39 +49,43 @@ unsafe extern "C" fn module_startup(_type: c_int, module_number: c_int) -> c_int
49
49
class_entity. declare_properties ( ce) ;
50
50
}
51
51
52
- match take ( & mut module. module_init ) {
53
- Some ( f) => f ( ) as c_int ,
54
- None => 1 ,
52
+ if let Some ( f) = take ( & mut module. module_init ) {
53
+ f ( ) ;
55
54
}
55
+
56
+ ZEND_RESULT_CODE_SUCCESS
56
57
}
57
58
58
59
unsafe extern "C" fn module_shutdown ( _type : c_int , module_number : c_int ) -> c_int {
59
60
let module = GLOBAL_MODULE . as_mut ( ) . unwrap ( ) ;
60
61
61
62
ini:: unregister ( module_number) ;
62
63
63
- match take ( & mut module. module_shutdown ) {
64
- Some ( f) => f ( ) as c_int ,
65
- None => 1 ,
64
+ if let Some ( f) = take ( & mut module. module_shutdown ) {
65
+ f ( ) ;
66
66
}
67
+
68
+ ZEND_RESULT_CODE_SUCCESS
67
69
}
68
70
69
71
unsafe extern "C" fn request_startup ( _type : c_int , _module_number : c_int ) -> c_int {
70
72
let module = GLOBAL_MODULE . as_ref ( ) . unwrap ( ) ;
71
73
72
- match & module. request_init {
73
- Some ( f) => f ( ) as c_int ,
74
- None => 1 ,
74
+ if let Some ( f) = & module. request_init {
75
+ f ( ) ;
75
76
}
77
+
78
+ ZEND_RESULT_CODE_SUCCESS
76
79
}
77
80
78
81
unsafe extern "C" fn request_shutdown ( _type : c_int , _module_number : c_int ) -> c_int {
79
82
let module = GLOBAL_MODULE . as_ref ( ) . unwrap ( ) ;
80
83
81
- match & module. request_shutdown {
82
- Some ( f) => f ( ) as c_int ,
83
- None => 1 ,
84
+ if let Some ( f) = & module. request_shutdown {
85
+ f ( ) ;
84
86
}
87
+
88
+ ZEND_RESULT_CODE_SUCCESS
85
89
}
86
90
87
91
unsafe extern "C" fn module_info ( zend_module : * mut zend_module_entry ) {
@@ -108,10 +112,10 @@ pub struct Module {
108
112
name : CString ,
109
113
version : CString ,
110
114
author : CString ,
111
- module_init : Option < Box < dyn FnOnce ( ) -> bool + Send + Sync > > ,
112
- module_shutdown : Option < Box < dyn FnOnce ( ) -> bool + Send + Sync > > ,
113
- request_init : Option < Box < dyn Fn ( ) -> bool + Send + Sync > > ,
114
- request_shutdown : Option < Box < dyn Fn ( ) -> bool + Send + Sync > > ,
115
+ module_init : Option < Box < dyn FnOnce ( ) > > ,
116
+ module_shutdown : Option < Box < dyn FnOnce ( ) > > ,
117
+ request_init : Option < Box < dyn Fn ( ) > > ,
118
+ request_shutdown : Option < Box < dyn Fn ( ) > > ,
115
119
function_entities : Vec < FunctionEntity > ,
116
120
class_entities : Vec < ClassEntity < ( ) > > ,
117
121
constants : Vec < Constant > ,
@@ -141,22 +145,22 @@ impl Module {
141
145
}
142
146
143
147
/// Register `MINIT` hook.
144
- pub fn on_module_init ( & mut self , func : impl FnOnce ( ) -> bool + Send + Sync + ' static ) {
148
+ pub fn on_module_init ( & mut self , func : impl FnOnce ( ) + ' static ) {
145
149
self . module_init = Some ( Box :: new ( func) ) ;
146
150
}
147
151
148
152
/// Register `MSHUTDOWN` hook.
149
- pub fn on_module_shutdown ( & mut self , func : impl FnOnce ( ) -> bool + Send + Sync + ' static ) {
153
+ pub fn on_module_shutdown ( & mut self , func : impl FnOnce ( ) + ' static ) {
150
154
self . module_shutdown = Some ( Box :: new ( func) ) ;
151
155
}
152
156
153
157
/// Register `RINIT` hook.
154
- pub fn on_request_init ( & mut self , func : impl Fn ( ) -> bool + Send + Sync + ' static ) {
158
+ pub fn on_request_init ( & mut self , func : impl Fn ( ) + ' static ) {
155
159
self . request_init = Some ( Box :: new ( func) ) ;
156
160
}
157
161
158
162
/// Register `RSHUTDOWN` hook.
159
- pub fn on_request_shutdown ( & mut self , func : impl Fn ( ) -> bool + Send + Sync + ' static ) {
163
+ pub fn on_request_shutdown ( & mut self , func : impl Fn ( ) + ' static ) {
160
164
self . request_shutdown = Some ( Box :: new ( func) ) ;
161
165
}
162
166
0 commit comments