From 20e6e9fa2035ac12946bf0dcd5b8049090955bde Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 23 Feb 2021 21:27:28 +0100 Subject: Update sled & try to debug deadlock (but its in sled...) --- src/rpc/rpc_server.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/rpc/rpc_server.rs') diff --git a/src/rpc/rpc_server.rs b/src/rpc/rpc_server.rs index 4113f15b..1c6bc8d2 100644 --- a/src/rpc/rpc_server.rs +++ b/src/rpc/rpc_server.rs @@ -48,6 +48,12 @@ where let begin_time = Instant::now(); let whole_body = hyper::body::to_bytes(req.into_body()).await?; let msg = rmp_serde::decode::from_read::<_, M>(whole_body.into_buf())?; + + trace!( + "Request message: {}", + serde_json::to_string(&msg).unwrap_or("".into()) + ); + match handler(msg, sockaddr).await { Ok(resp) => { let resp_bytes = rmp_to_vec_all_named::>(&Ok(resp))?; @@ -112,7 +118,8 @@ impl RpcServer { return Ok(bad_request); } - let path = &req.uri().path()[1..]; + let path = &req.uri().path()[1..].to_string(); + let handler = match self.handlers.get(path) { Some(h) => h, None => { @@ -122,6 +129,8 @@ impl RpcServer { } }; + trace!("({}) Handling request", path); + let resp_waiter = tokio::spawn(handler(req, addr)); match resp_waiter.await { Err(err) => { @@ -131,11 +140,15 @@ impl RpcServer { Ok(ise) } Ok(Err(err)) => { + trace!("({}) Request handler failed: {}", path, err); let mut bad_request = Response::new(Body::from(format!("{}", err))); *bad_request.status_mut() = StatusCode::BAD_REQUEST; Ok(bad_request) } - Ok(Ok(resp)) => Ok(resp), + Ok(Ok(resp)) => { + trace!("({}) Request handler succeeded", path); + Ok(resp) + } } } -- cgit v1.2.3