From c25897b0cf9237f0f900a99c3d09fe7f743e2561 Mon Sep 17 00:00:00 2001 From: Ryan Thomas Date: Wed, 26 Oct 2022 13:04:20 +1100 Subject: [PATCH 1/2] Doc change for when timeouts may not fire. From discussion on #5119. --- tokio/src/time/timeout.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tokio/src/time/timeout.rs b/tokio/src/time/timeout.rs index c7f24410783..a2a4a50f80d 100644 --- a/tokio/src/time/timeout.rs +++ b/tokio/src/time/timeout.rs @@ -21,6 +21,10 @@ use std::task::{self, Poll}; /// value is returned. Otherwise, an error is returned and the future is /// canceled. /// +/// Note that if the future does not yield during execution then it is possible +/// for the future to complete and exceed the timeout _without_ returning an +/// error. +/// /// This function returns a future whose return type is [`Result`]``, where `T` is the /// return type of the provided future. /// From 2e6b6c7b1b04bf075deeb9f4cbda234da19ee750 Mon Sep 17 00:00:00 2001 From: Ryan Thomas Date: Thu, 27 Oct 2022 07:42:27 +1100 Subject: [PATCH 2/2] Update tokio/src/time/timeout.rs Co-authored-by: Alice Ryhl --- tokio/src/time/timeout.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tokio/src/time/timeout.rs b/tokio/src/time/timeout.rs index a2a4a50f80d..c6adfd935b7 100644 --- a/tokio/src/time/timeout.rs +++ b/tokio/src/time/timeout.rs @@ -21,9 +21,9 @@ use std::task::{self, Poll}; /// value is returned. Otherwise, an error is returned and the future is /// canceled. /// -/// Note that if the future does not yield during execution then it is possible -/// for the future to complete and exceed the timeout _without_ returning an -/// error. +/// Note that the timeout is checked before polling the future, so if the future +/// does not yield during execution then it is possible for the future to complete +/// and exceed the timeout _without_ returning an error. /// /// This function returns a future whose return type is [`Result`]``, where `T` is the /// return type of the provided future.