From 278383f12f6ea71029610a235f6910be6b81ff53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=9C=AA=E6=9D=A5?= Date: Mon, 21 Apr 2025 11:01:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4cancel=20safe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 徐未来 --- .../src/async_impl/conn/http1.rs | 2 -- ylong_http_client/src/async_impl/pool.rs | 3 +- ylong_http_client/src/util/dispatcher.rs | 34 ------------------- 3 files changed, 1 insertion(+), 38 deletions(-) diff --git a/ylong_http_client/src/async_impl/conn/http1.rs b/ylong_http_client/src/async_impl/conn/http1.rs index 40e115c..8fb4470 100644 --- a/ylong_http_client/src/async_impl/conn/http1.rs +++ b/ylong_http_client/src/async_impl/conn/http1.rs @@ -56,7 +56,6 @@ where .ref_mut() .time_group_mut() .set_transfer_start(Instant::now()); - conn.running(true); encode_request_part( message.request.ref_mut(), &message.interceptor, @@ -102,7 +101,6 @@ where } } }; - conn.running(false); decode_response(message, part, conn, pre) } diff --git a/ylong_http_client/src/async_impl/pool.rs b/ylong_http_client/src/async_impl/pool.rs index ded7cff..a8a5a7f 100644 --- a/ylong_http_client/src/async_impl/pool.rs +++ b/ylong_http_client/src/async_impl/pool.rs @@ -448,8 +448,7 @@ impl Conns // TODO Distinguish between http2 connections and http1 connections. for dispatcher in curr.into_iter() { // Discard invalid dispatchers. - // Running dispatchers means tcp canceled while read and write. - if dispatcher.is_shutdown() || dispatcher.is_running() { + if dispatcher.is_shutdown() { continue; } if conn.is_none() { diff --git a/ylong_http_client/src/util/dispatcher.rs b/ylong_http_client/src/util/dispatcher.rs index 4e8f5dc..cee41ef 100644 --- a/ylong_http_client/src/util/dispatcher.rs +++ b/ylong_http_client/src/util/dispatcher.rs @@ -23,8 +23,6 @@ pub(crate) trait Dispatcher { #[allow(dead_code)] fn is_goaway(&self) -> bool; - - fn is_running(&self) -> bool; } pub(crate) enum ConnDispatcher { @@ -79,19 +77,6 @@ impl Dispatcher for ConnDispatcher { Self::Http3(h3) => h3.is_goaway(), } } - - fn is_running(&self) -> bool { - match self { - #[cfg(feature = "http1_1")] - Self::Http1(h1) => h1.is_running(), - - #[cfg(feature = "http2")] - Self::Http2(h2) => h2.is_running(), - - #[cfg(feature = "http3")] - Self::Http3(h3) => h3.is_running(), - } - } } pub(crate) enum Conn { @@ -173,8 +158,6 @@ pub(crate) mod http1 { pub(crate) occupied: AtomicBool, // `shutdown` indicates that the connection need to be shut down. pub(crate) shutdown: AtomicBool, - // `running` indicates that the connection is cancelled during use. - pub(crate) running: AtomicBool, } unsafe impl Sync for Inner {} @@ -186,7 +169,6 @@ pub(crate) mod http1 { io: UnsafeCell::new(io), occupied: AtomicBool::new(false), shutdown: AtomicBool::new(false), - running: AtomicBool::new(false), }), } } @@ -210,10 +192,6 @@ pub(crate) mod http1 { fn is_goaway(&self) -> bool { false } - - fn is_running(&self) -> bool { - self.inner.running.load(Ordering::Relaxed) - } } /// Handle returned to other threads for I/O operations. @@ -245,10 +223,6 @@ pub(crate) mod http1 { pub(crate) fn shutdown(&self) { self.inner.shutdown.store(true, Ordering::Release); } - - pub(crate) fn running(&self, is_run:bool) { - self.inner.running.store(is_run, Ordering::Release); - } } impl Drop for Http1Conn { @@ -552,10 +526,6 @@ pub(crate) mod http2 { fn is_goaway(&self) -> bool { self.io_goaway.load(Ordering::Relaxed) } - - fn is_running(&self) -> bool { - todo!() - } } impl Drop for Http2Dispatcher { @@ -1051,10 +1021,6 @@ pub(crate) mod http3 { fn is_goaway(&self) -> bool { self.io_goaway.load(Ordering::Relaxed) } - - fn is_running(&self) -> bool { - todo!() - } } impl Drop for Http3Dispatcher { -- Gitee