Skip to content

Commit

Permalink
feat(swarm): remove KeepAlive::Until from OneshotHandler
Browse files Browse the repository at this point in the history
Related: #3844.
Related: #4656.

Pull-Request: #4677.
  • Loading branch information
leonzchang authored Oct 20, 2023
1 parent 781405b commit b1b46d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
2 changes: 2 additions & 0 deletions swarm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 0.44.0 - unreleased

- Remove deprecated `keep_alive_timeout` in `OneShotHandlerConfig`.
See [PR 4677](https://github.com/libp2p/rust-libp2p/pull/4677).

## 0.43.6

Expand Down
22 changes: 2 additions & 20 deletions swarm/src/handler/one_shot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use crate::handler::{
SubstreamProtocol,
};
use crate::upgrade::{InboundUpgradeSend, OutboundUpgradeSend};
use instant::Instant;
use smallvec::SmallVec;
use std::{error, fmt::Debug, task::Context, task::Poll, time::Duration};

Expand Down Expand Up @@ -176,9 +175,8 @@ where
} else {
self.dial_queue.shrink_to_fit();

#[allow(deprecated)]
if self.dial_negotiated == 0 && self.keep_alive.is_yes() {
self.keep_alive = KeepAlive::Until(Instant::now() + self.config.keep_alive_timeout);
self.keep_alive = KeepAlive::No;
}
}

Expand All @@ -199,13 +197,6 @@ where
protocol: out,
..
}) => {
// If we're shutting down the connection for inactivity, reset the timeout.
#[allow(deprecated)]
if !self.keep_alive.is_yes() {
self.keep_alive =
KeepAlive::Until(Instant::now() + self.config.keep_alive_timeout);
}

self.events_out.push(out.into());
}
ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound {
Expand All @@ -232,11 +223,6 @@ where
/// Configuration parameters for the `OneShotHandler`
#[derive(Debug)]
pub struct OneShotHandlerConfig {
/// Keep-alive timeout for idle connections.
#[deprecated(
note = "Set a global idle connection timeout via `SwarmBuilder::idle_connection_timeout` instead."
)]
pub keep_alive_timeout: Duration,
/// Timeout for outbound substream upgrades.
pub outbound_substream_timeout: Duration,
/// Maximum number of concurrent outbound substreams being opened.
Expand All @@ -247,7 +233,6 @@ impl Default for OneShotHandlerConfig {
#[allow(deprecated)]
fn default() -> Self {
OneShotHandlerConfig {
keep_alive_timeout: Duration::from_secs(10),
outbound_substream_timeout: Duration::from_secs(10),
max_dial_negotiated: 8,
}
Expand Down Expand Up @@ -277,9 +262,6 @@ mod tests {
}
}));

assert!(matches!(
handler.connection_keep_alive(),
KeepAlive::Until(_)
));
assert!(matches!(handler.connection_keep_alive(), KeepAlive::No));
}
}

0 comments on commit b1b46d1

Please sign in to comment.