@@ -25,7 +25,6 @@ use once_cell::sync::Lazy;
2525use phper:: { arrays:: ZArr , eg, pg, sg, sys, values:: ZVal } ;
2626use skywalking:: trace:: { propagation:: decoder:: decode_propagation, tracer} ;
2727use std:: {
28- convert:: Infallible ,
2928 panic:: AssertUnwindSafe ,
3029 ptr:: null_mut,
3130 sync:: atomic:: { AtomicBool , AtomicPtr , Ordering } ,
@@ -146,6 +145,9 @@ fn get_page_request_server<'a>() -> anyhow::Result<&'a ZArr> {
146145 }
147146}
148147
148+ pub const HACK_SWOOLE_ON_REQUEST_FUNCTION_NAME : & str =
149+ "skywalking_hack_swoole_on_request_please_do_not_use" ;
150+
149151/// Hold the response fd and status code kvs, because I dont't found that
150152/// response has the status field, so I hook the response.status method, maybe
151153/// there is a better way?
@@ -157,11 +159,11 @@ pub static IS_SWOOLE: AtomicBool = AtomicBool::new(false);
157159
158160/// The function is used by swoole plugin, to surround the callback of on
159161/// request.
160- pub fn skywalking_hack_swoole_on_request ( args : & mut [ ZVal ] ) -> Result < ( ) , Infallible > {
162+ pub fn skywalking_hack_swoole_on_request ( args : & mut [ ZVal ] ) -> phper :: Result < ZVal > {
161163 let f = ORI_SWOOLE_ON_REQUEST . load ( Ordering :: Relaxed ) ;
162164 if f. is_null ( ) {
163165 error ! ( "Origin swoole on request handler is null" ) ;
164- return Ok ( ( ) ) ;
166+ return Ok ( ZVal :: from ( ( ) ) ) ;
165167 }
166168 let f = unsafe { ZVal :: from_mut_ptr ( f) } ;
167169
@@ -170,7 +172,8 @@ pub fn skywalking_hack_swoole_on_request(args: &mut [ZVal]) -> Result<(), Infall
170172 error ! ( mode = "swoole" , ?err, "request init failed" ) ;
171173 }
172174
173- if let Err ( err) = f. call ( & mut * args) {
175+ let return_value = f. call ( & mut * args) ;
176+ if let Err ( err) = & return_value {
174177 error ! (
175178 mode = "swoole" ,
176179 ?err,
@@ -186,7 +189,7 @@ pub fn skywalking_hack_swoole_on_request(args: &mut [ZVal]) -> Result<(), Infall
186189 }
187190 }
188191
189- Ok ( ( ) )
192+ return_value
190193}
191194
192195fn request_init_for_swoole ( request : & mut ZVal ) -> crate :: Result < ( ) > {
0 commit comments