Repository navigation
fix(body): start read_timeout timer when polling next frame - #3118
Open
princejain756 wants to merge 2 commits into
Open
princejain756 wants to merge 2 commits into
princejain756 wants to merge 2 commits into
Conversation
Since seanmonstar#3085, ReadTimeoutBody::poll_frame reset its reused Sleep timer as soon as a frame finished rather than when the next frame poll began. Any caller pause between reads therefore counted against the next read's read_timeout. Track whether the timer is armed for an in-progress frame poll so the reused Sleep is only reset when a new frame poll starts, and disarmed once inner.poll_frame yields Poll::Ready. Fixes seanmonstar#3115
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since #3085,
ReadTimeoutBody::poll_framereset its reusedtokio::time::Sleeptimer as soon as a frame completed (Poll::Ready) rather than when the caller began polling for the next frame. Any time the caller spent between reads therefore counted against the next read'sread_timeout, causingresp.chunk().awaitto time out after a caller pause even when all data (or EOF) had already arrived.Changes
armed: boolonReadTimeoutBodyso the reusedSleepinstance is reset at the start of a new frame poll (!*this.armed) and disarmed (*this.armed = false) whenthis.inner.poll_frame(cx)returnsPoll::Ready.Instant::now()on subsequent polls of an already-pending frame while preserving theSleepallocation reuse from perf(body): reuse tokio::time::Sleep timer via reset() in ReadTimeoutBody #3085.read_timeout_ignores_time_between_readsintests/timeouts.rs.Fixes #3115