|
|
|
@ -29,6 +29,7 @@ use chrono::{
|
|
|
|
|
Utc
|
|
|
|
|
};
|
|
|
|
|
use dashmap::DashMap;
|
|
|
|
|
use futures_util::StreamExt;
|
|
|
|
|
use handlebars::Handlebars;
|
|
|
|
|
use hyper::{
|
|
|
|
|
Body,
|
|
|
|
@ -47,6 +48,7 @@ use tokio::{
|
|
|
|
|
oneshot,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
use tokio_stream::wrappers::ReceiverStream;
|
|
|
|
|
|
|
|
|
|
use ptth_core::{
|
|
|
|
|
http_serde,
|
|
|
|
@ -166,7 +168,7 @@ async fn handle_http_request (
|
|
|
|
|
request_rendezvous.insert (watcher_code, new_rendezvous);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let timeout = tokio::time::delay_for (std::time::Duration::from_secs (30));
|
|
|
|
|
let timeout = tokio::time::sleep (std::time::Duration::from_secs (30));
|
|
|
|
|
|
|
|
|
|
let received = tokio::select! {
|
|
|
|
|
val = rx => val,
|
|
|
|
@ -305,8 +307,6 @@ async fn handle_server_list (
|
|
|
|
|
|
|
|
|
|
async fn handle_endless_sink (req: Request <Body>) -> Result <Response <Body>, http::Error>
|
|
|
|
|
{
|
|
|
|
|
use tokio::stream::StreamExt;
|
|
|
|
|
|
|
|
|
|
let (_parts, mut body) = req.into_parts ();
|
|
|
|
|
|
|
|
|
|
let mut bytes_received = 0;
|
|
|
|
@ -339,8 +339,6 @@ async fn handle_endless_source (gib: usize, throttle: Option <usize>)
|
|
|
|
|
let (tx, rx) = mpsc::channel (1);
|
|
|
|
|
|
|
|
|
|
tokio::spawn (async move {
|
|
|
|
|
let mut tx = tx;
|
|
|
|
|
|
|
|
|
|
let random_block = {
|
|
|
|
|
use rand::RngCore;
|
|
|
|
|
|
|
|
|
@ -374,7 +372,7 @@ async fn handle_endless_source (gib: usize, throttle: Option <usize>)
|
|
|
|
|
Response::builder ()
|
|
|
|
|
.status (StatusCode::OK)
|
|
|
|
|
.header ("content-type", "application/octet-stream")
|
|
|
|
|
.body (Body::wrap_stream (rx))
|
|
|
|
|
.body (Body::wrap_stream (ReceiverStream::new (rx)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[instrument (level = "trace", skip (req, state, handlebars))]
|
|
|
|
@ -564,7 +562,7 @@ pub async fn run_relay (
|
|
|
|
|
|
|
|
|
|
shutdown_oneshot.await.ok ();
|
|
|
|
|
|
|
|
|
|
state.shutdown_watch_tx.broadcast (true).expect ("Can't broadcast graceful shutdown");
|
|
|
|
|
state.shutdown_watch_tx.send (true).expect ("Can't broadcast graceful shutdown");
|
|
|
|
|
|
|
|
|
|
let mut response_rendezvous = state.response_rendezvous.write ().await;
|
|
|
|
|
let mut swapped = DashMap::default ();
|
|
|
|
|