From e618eeb386627a9a7c0f10672499ffe9a7266b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Thu, 13 Aug 2020 12:06:53 +0200 Subject: [PATCH] Fix a isse that might occur when a participant is dropped while the remote wants to open a Stream and we get some bad time condition. increase the slowlorris timeout. for some reason it seems to trigger alot more often since commit: `75c1d440` but i have no idea why. My guess would be that the initial sync now sends way more data which slows down TCP to be > 10ms and trigger. Note: the fix might cause small lags when slow people try to connect to the server --- network/src/participant.rs | 11 +++++++++-- server/src/lib.rs | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/network/src/participant.rs b/network/src/participant.rs index d2035b9989..085ddfcb77 100644 --- a/network/src/participant.rs +++ b/network/src/participant.rs @@ -331,12 +331,19 @@ impl BParticipant { prio, promises, } => { + trace!(?sid, ?prio, ?promises, "Opened frame from remote"); let a2p_msg_s = a2p_msg_s.clone(); let stream = self .create_stream(sid, prio, promises, a2p_msg_s, &a2b_close_stream_s) .await; - b2a_stream_opened_s.send(stream).await.unwrap(); - trace!("Opened frame from remote"); + if let Err(e) = b2a_stream_opened_s.send(stream).await { + warn!( + ?e, + ?sid, + "couldn't notify api::Participant that a stream got opened. Is the \ + participant already dropped?" + ); + } }, Frame::CloseStream { sid } => { // Closing is realised by setting a AtomicBool to true, however we also have a diff --git a/server/src/lib.rs b/server/src/lib.rs index e958ec53a3..241c9588f8 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -638,6 +638,7 @@ impl Server { ) -> Result<(), Error> { //TIMEOUT 0.1 ms for msg handling const TIMEOUT: Duration = Duration::from_micros(100); + const SLOWLORIS_TIMEOUT: Duration = Duration::from_millis(300); loop { let participant = match select!( _ = Delay::new(TIMEOUT).fuse() => None, @@ -649,7 +650,7 @@ impl Server { debug!("New Participant connected to the server"); let singleton_stream = match select!( - _ = Delay::new(TIMEOUT*100).fuse() => None, + _ = Delay::new(SLOWLORIS_TIMEOUT).fuse() => None, sr = participant.opened().fuse() => Some(sr), ) { None => {