From 0471cb032229e78b4b955f9649e77fc30dc675e1 Mon Sep 17 00:00:00 2001 From: Waffle Date: Fri, 23 Jul 2021 20:08:26 +0300 Subject: [PATCH] Use `tokio::task::unconstrained` when using `.now_or_never()` to prevent some problems I guess The issue in fixme says to use `tokio::task::unconstrained`. --- src/adaptors/throttle.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/adaptors/throttle.rs b/src/adaptors/throttle.rs index b741ac35..36d6d880 100644 --- a/src/adaptors/throttle.rs +++ b/src/adaptors/throttle.rs @@ -495,7 +495,7 @@ async fn worker( fn answer_info(rx: &mut mpsc::Receiver, limits: &mut Limits) { // FIXME(waffle): https://github.com/tokio-rs/tokio/issues/3350 - while let Some(Some(req)) = rx.recv().now_or_never() { + while let Some(Some(req)) = tokio::task::unconstrained(rx.recv()).now_or_never() { // Errors are ignored with .ok(). Error means that the response channel // is closed and the response isn't needed. match req { @@ -519,7 +519,7 @@ async fn read_from_rx(rx: &mut mpsc::Receiver, queue: &mut Vec, rx_is_c // Don't grow queue bigger than the capacity to limit DOS posibility while queue.len() < queue.capacity() { // FIXME(waffle): https://github.com/tokio-rs/tokio/issues/3350 - match rx.recv().now_or_never() { + match tokio::task::unconstrained(rx.recv()).now_or_never() { Some(Some(req)) => queue.push(req), Some(None) => *rx_is_closed = true, // There are no items in queue.