From 453532e48ebd08ec654fbf50f2629a8b895a3852 Mon Sep 17 00:00:00 2001 From: _ <> Date: Tue, 16 Mar 2021 15:15:16 +0000 Subject: [PATCH] add listen ID to http_listen --- crates/ptth_relay/src/lib.rs | 2 +- crates/ptth_relay/src/server_endpoint.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/ptth_relay/src/lib.rs b/crates/ptth_relay/src/lib.rs index 5154644..acfe508 100644 --- a/crates/ptth_relay/src/lib.rs +++ b/crates/ptth_relay/src/lib.rs @@ -441,7 +441,7 @@ async fn handle_all ( let path = req.uri ().path ().to_string (); //println! ("{}", path); - debug! ("Request path: {}", path); + trace! ("Request path: {}", path); if req.method () == Method::POST { // This is stuff the server can use. Clients can't diff --git a/crates/ptth_relay/src/server_endpoint.rs b/crates/ptth_relay/src/server_endpoint.rs index 18e779b..f38343c 100644 --- a/crates/ptth_relay/src/server_endpoint.rs +++ b/crates/ptth_relay/src/server_endpoint.rs @@ -99,6 +99,8 @@ pub async fn handle_listen ( let (tx, rx) = oneshot::channel (); + let listen_id = ulid::Ulid::new ().to_string (); + { let mut request_rendezvous = state.request_rendezvous.lock ().await; @@ -113,7 +115,7 @@ pub async fn handle_listen ( } } - trace! ("Parking server {}", watcher_code); + debug! ("Parking server {}, listen id {}", watcher_code, listen_id); request_rendezvous.insert (watcher_code.clone (), ParkedServer (tx)); } @@ -127,12 +129,12 @@ pub async fn handle_listen ( }, Ok (Err (ShuttingDownError::ShuttingDown)) => Ok (error_reply (StatusCode::SERVICE_UNAVAILABLE, "Server is shutting down, try again soon")?), Err (e) => { - error! ("{} {}", watcher_code, e); + error! ("{} {} {}", watcher_code, listen_id, e); Ok (error_reply (StatusCode::INTERNAL_SERVER_ERROR, "Server error")?) }, }, _ = tokio::time::sleep (Duration::from_secs (30)).fuse () => { - trace! ("Timed out http_listen for server {}", watcher_code); + debug! ("Timed out http_listen for server {} {}", watcher_code, listen_id); return Ok (error_reply (StatusCode::NO_CONTENT, "No requests now, long-poll again")?) } }