Skip to content

Commit eb3dec2

Browse files
authored
refactor(body): use absolute read timeout deadline (#1231)
1 parent 99efbbf commit eb3dec2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/client/layer/timeout/body.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,10 @@ where
206206
) -> Poll<Option<Result<http_body::Frame<Self::Data>, Self::Error>>> {
207207
let mut this = self.project();
208208

209-
// Error if the timeout has expired.
209+
// Start the timeout on the first poll.
210210
if this.sleep.is_none() {
211-
this.sleep.set(Some(this.timer.sleep(*this.timeout)));
211+
let deadline = this.timer.now() + *this.timeout;
212+
this.sleep.set(Some(this.timer.sleep_until(deadline)));
212213
}
213214

214215
// Error if the timeout has expired.

0 commit comments

Comments
 (0)