Reset pacing timer

The pacing implementation did so far not do anything. The reason for
that is the timestamp when tokens had been last generated was never
updated. Therefore each Pacer::delay call where not enough tokens
had been available calculated tokens based on the time back to when
the Pacer was initially created, which fully refills the capacity.

This is easily fixed by storing the timestamp when tokens are replenished.
This commit is contained in:
Matthias Einwag
2021-01-20 19:16:25 +00:00
committed by Dirkjan Ochtman
parent 49e57a2f41
commit 728fdb9b61
+2
View File
@@ -75,6 +75,8 @@ impl Pacer {
.saturating_add(new_tokens as _)
.min(self.capacity);
self.prev = now;
// if we can already send a packet, there is no need for delay
if self.tokens > mtu.into() {
return None;