Skip to content

Commit

Permalink
fix(server): reschedule keep alive interval timer once a pong is rece…
Browse files Browse the repository at this point in the history
…ived

`KeepAliveState` did not transition from `PingSent` to `Scheduled` after
a pong was received. This prevented more than one ping to be sent by the
server. This fix checks if `ping_sent_at` has already been cleared by
`Ponger::poll` when `KeepAliveState::PingSent` state is active.

Fixes #2310
  • Loading branch information
pdcalado authored and seanmonstar committed Oct 29, 2020
1 parent f288641 commit 2a938d9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/proto/h2/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,16 @@ impl KeepAlive {
let interval = shared.last_read_at() + self.interval;
self.timer.reset(interval);
}
KeepAliveState::Scheduled | KeepAliveState::PingSent => (),
KeepAliveState::PingSent => {
if shared.is_ping_sent() {
return;
}

self.state = KeepAliveState::Scheduled;
let interval = shared.last_read_at() + self.interval;
self.timer.reset(interval);
}
KeepAliveState::Scheduled => (),
}
}

Expand Down

0 comments on commit 2a938d9

Please sign in to comment.