Skip to content

Commit 2a938d9

Browse files
pdcaladoseanmonstar
authored andcommitted
fix(server): reschedule keep alive interval timer once a pong is received
`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
1 parent f288641 commit 2a938d9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/proto/h2/ping.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,16 @@ impl KeepAlive {
442442
let interval = shared.last_read_at() + self.interval;
443443
self.timer.reset(interval);
444444
}
445-
KeepAliveState::Scheduled | KeepAliveState::PingSent => (),
445+
KeepAliveState::PingSent => {
446+
if shared.is_ping_sent() {
447+
return;
448+
}
449+
450+
self.state = KeepAliveState::Scheduled;
451+
let interval = shared.last_read_at() + self.interval;
452+
self.timer.reset(interval);
453+
}
454+
KeepAliveState::Scheduled => (),
446455
}
447456
}
448457

0 commit comments

Comments
 (0)