Skip to content

Commit

Permalink
Merge branch 'master' into mwe/cycles128
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-weigelt authored Dec 11, 2024
2 parents b5a3782 + 235d88f commit ec9bb66
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rs/p2p/quic_transport/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ DEPENDENCIES = [
"@crate_index//:rustls",
"@crate_index//:slog",
"@crate_index//:socket2",
"@crate_index//:static_assertions",
"@crate_index//:thiserror",
"@crate_index//:tokio",
"@crate_index//:tokio-metrics",
Expand Down
1 change: 1 addition & 0 deletions rs/p2p/quic_transport/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ prost = { workspace = true }
quinn = { workspace = true }
rustls = { workspace = true }
slog = { workspace = true }
static_assertions = { workspace = true }
socket2 = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
Expand Down
10 changes: 9 additions & 1 deletion rs/p2p/quic_transport/src/connection_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use quinn::{
};
use rustls::pki_types::CertificateDer;
use socket2::{Domain, Protocol, SockAddr, Socket, Type};
use static_assertions::const_assert;
use thiserror::Error;
use tokio::{runtime::Handle, select, task::JoinSet};
use tokio_util::{sync::CancellationToken, time::DelayQueue};
Expand Down Expand Up @@ -79,7 +80,14 @@ const KEEP_ALIVE_INTERVAL: Duration = Duration::from_secs(1);
/// that were not explicitly closed. I.e replica crash
const IDLE_TIMEOUT: Duration = Duration::from_secs(5);
const CONNECT_TIMEOUT: Duration = Duration::from_secs(10);
const CONNECT_RETRY_BACKOFF: Duration = Duration::from_secs(3);
const CONNECT_RETRY_BACKOFF: Duration = Duration::from_secs(5);

// There should be least two probes before timing out a connection.
const_assert!(KEEP_ALIVE_INTERVAL.as_nanos() < IDLE_TIMEOUT.as_nanos());
// The application level timeout should no less than the QUIC idle timeout.
const_assert!(IDLE_TIMEOUT.as_nanos() <= CONNECT_TIMEOUT.as_nanos());
// The waiting time before re-trying to connect should be no less than the IDLE_TIMEOUT.
const_assert!(IDLE_TIMEOUT.as_nanos() <= CONNECT_RETRY_BACKOFF.as_nanos());

/// Connection manager is responsible for making sure that
/// there always exists a healthy connection to each peer
Expand Down

0 comments on commit ec9bb66

Please sign in to comment.