Skip to content

Commit

Permalink
Fix ping sending after change in tokio Interval API
Browse files Browse the repository at this point in the history
With tokio 1.27.0, the Interval type changed in backwards incompatible
ways, now necessitating a call to Interval::reset to schedule another
wake up [0].
This change makes sure that we follow the new procedure.

[0]: tokio-rs/tokio#5553
  • Loading branch information
d-e-s-o committed Jun 26, 2023
1 parent 8b3828d commit 754af03
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,7 @@
Unreleased
----------
- Fixed ping sending after change in `tokio` `Interval` API with version
`1.27.0`
- Switched to using Rust 2021 Edition


Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -27,7 +27,7 @@ tokio-tungstenite = {version = "0.18", default-features = false, features = ["co
rand = {version = "0.8", default-features = false, features = ["std", "std_rng"]}
serde = {version = "1.0", features = ["derive"]}
test-log = {version = "0.2.8", default-features = false, features = ["trace"]}
tokio = {version = "1.0", default-features = false, features = ["rt", "macros", "net"]}
tokio = {version = "1.27", default-features = false, features = ["rt", "macros", "net"]}
tracing-subscriber = {version = "0.3", default-features = false, features = ["ansi", "env-filter", "fmt", "local-time"]}
url = "2.0"

Expand Down
4 changes: 4 additions & 0 deletions src/wrap.rs
Expand Up @@ -225,6 +225,10 @@ impl Pinger {

match self.next_ping.poll_tick(ctx) {
StdPoll::Ready(_) => {
// When using the `poll_tick` API, we are on the hook for
// resetting the interval to be woken up again when it passed.
let () = self.next_ping.reset();

// We are due sending a ping according to the user's specified
// ping interval. Check the existing ping state to decide what
// to actually do. We may not need to send a ping if we can
Expand Down

0 comments on commit 754af03

Please sign in to comment.