diff --git a/build.bash b/build.bash new file mode 100755 index 0000000..68d5058 --- /dev/null +++ b/build.bash @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +sudo docker build -t ptth . diff --git a/src/server/mod.rs b/src/server/mod.rs index 4c74381..0d23170 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -42,7 +42,7 @@ fn status_reply (c: http_serde::StatusCode, body: &str) -> http_serde::Response async fn handle_req_resp <'a> ( state: &Arc , req_resp: reqwest::Response -) { +) -> Result <(), ()> { //println! ("Step 1"); let body = req_resp.bytes ().await.unwrap (); @@ -51,7 +51,7 @@ async fn handle_req_resp <'a> ( Ok (x) => x, Err (e) => { error! ("Can't parse wrapped requests: {:?}", e); - return; + return Err (()); }, }; @@ -118,6 +118,8 @@ async fn handle_req_resp <'a> ( }); } + + Ok (()) } #[derive (Default, Deserialize)] @@ -204,10 +206,6 @@ pub async fn run_server ( Err (e) => { if e.is_timeout () { error! ("Client-side timeout. Is an overly-aggressive firewall closing long-lived connections? Is the network flakey?"); - if backoff_delay != 0 { - debug! ("backoff_delay = 0"); - backoff_delay = 0; - } } else { error! ("Err: {:?}", e); @@ -219,10 +217,6 @@ pub async fn run_server ( continue; }, Ok (r) => { - if backoff_delay != 0 { - debug! ("backoff_delay = 0"); - backoff_delay = 0; - } r }, }; @@ -246,7 +240,15 @@ pub async fn run_server ( // Unpack the requests, spawn them into new tasks, then loop back // around. - handle_req_resp (&state, req_resp).await; + if handle_req_resp (&state, req_resp).await.is_err () { + backoff_delay = err_backoff_delay; + continue; + } + + if backoff_delay != 0 { + debug! ("backoff_delay = 0"); + backoff_delay = 0; + } } info! ("Exiting"); diff --git a/todo.md b/todo.md index ed1393c..e91173c 100644 --- a/todo.md +++ b/todo.md @@ -1,7 +1,6 @@ -- Not working behind Nginx -- Try sending the http_response "OK" _after_ the request body is received +- Not working behind Nginx (Works okay behind Caddy) +- Still getting the slow request turtle in FF - 500-900 ms wait time -- Sort directory listings - ".." from server to server list is broken - Redirect to add trailing slashes - Add file size in directory listing