There was an error while loading. Please reload this page.
1 parent aa0063a commit 585ba5fCopy full SHA for 585ba5f
1 file changed
src/client/layer/timeout/body.rs
@@ -221,8 +221,11 @@ where
221
// Poll the actual body
222
match ready!(this.body.poll_frame(cx)) {
223
Some(Ok(frame)) => {
224
- // Reset timeout on successful read
225
- this.sleep.set(None);
+ // Reuse the sleep to avoid allocating and registering a new timer for every frame.
+ if let Some(sleep) = this.sleep.as_mut().as_pin_mut() {
226
+ let deadline = this.timer.now() + *this.timeout;
227
+ this.timer.reset(sleep.get_mut(), deadline);
228
+ }
229
Poll::Ready(Some(Ok(frame)))
230
}
231
Some(Err(err)) => Poll::Ready(Some(Err(err.into()))),
0 commit comments