From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 65ECA7075D for ; Wed, 29 Sep 2021 09:04:23 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5681DF46B for ; Wed, 29 Sep 2021 09:04:23 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id D65E2F451 for ; Wed, 29 Sep 2021 09:04:21 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id AD0E742B65 for ; Wed, 29 Sep 2021 09:04:21 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Wed, 29 Sep 2021 09:04:18 +0200 Message-Id: <20210929070420.617226-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210929070420.617226-1-d.csapak@proxmox.com> References: <20210929070420.617226-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.346 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup v3 2/4] remove tools/async_io.rs X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Sep 2021 07:04:23 -0000 nothing from here is used anymore, so remove it Signed-off-by: Dominik Csapak --- src/tools/async_io.rs | 83 ------------------------------------------- src/tools/mod.rs | 1 - 2 files changed, 84 deletions(-) delete mode 100644 src/tools/async_io.rs diff --git a/src/tools/async_io.rs b/src/tools/async_io.rs deleted file mode 100644 index 66d38094..00000000 --- a/src/tools/async_io.rs +++ /dev/null @@ -1,83 +0,0 @@ -//! AsyncRead/AsyncWrite utilities. - -use std::os::unix::io::{AsRawFd, RawFd}; -use std::pin::Pin; -use std::task::{Context, Poll}; - -use futures::stream::{Stream, TryStream}; -use futures::ready; -use tokio::io::{AsyncRead, AsyncWrite}; -use tokio::net::TcpListener; - - -/// Tokio's `Incoming` now is a reference type and hyper's `AddrIncoming` misses some standard -/// stuff like `AsRawFd`, so here's something implementing hyper's `Accept` from a `TcpListener` -pub struct StaticIncoming(TcpListener); - -impl From for StaticIncoming { - fn from(inner: TcpListener) -> Self { - Self(inner) - } -} - -impl AsRawFd for StaticIncoming { - fn as_raw_fd(&self) -> RawFd { - self.0.as_raw_fd() - } -} - -impl hyper::server::accept::Accept for StaticIncoming { - type Conn = tokio::net::TcpStream; - type Error = std::io::Error; - - fn poll_accept( - self: Pin<&mut Self>, - cx: &mut Context, - ) -> Poll>> { - let this = self.get_mut(); - loop { - match ready!(this.0.poll_accept(cx)) { - Ok((conn, _addr)) => return Poll::Ready(Some(Ok(conn))), - Err(err) => { - eprintln!("error accepting connection: {}", err); - continue; - } - } - } - } -} - -/// We also implement TryStream for this, as tokio doesn't do this anymore either and we want to be -/// able to map connections to then add eg. ssl to them. This support code makes the changes -/// required for hyper 0.13 a bit less annoying to read. -impl Stream for StaticIncoming { - type Item = std::io::Result<(tokio::net::TcpStream, std::net::SocketAddr)>; - - fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { - match self.get_mut().0.poll_accept(cx) { - Poll::Pending => Poll::Pending, - Poll::Ready(result) => Poll::Ready(Some(result)), - } - } -} - -/// Implement hyper's `Accept` for any `TryStream` of sockets: -pub struct HyperAccept(pub T); - - -impl hyper::server::accept::Accept for HyperAccept -where - T: TryStream + Unpin, - I: AsyncRead + AsyncWrite, -{ - type Conn = I; - type Error = T::Error; - - fn poll_accept( - self: Pin<&mut Self>, - cx: &mut Context, - ) -> Poll>> { - let this = Pin::new(&mut self.get_mut().0); - this.try_poll_next(cx) - } -} diff --git a/src/tools/mod.rs b/src/tools/mod.rs index 5dc129f0..d8ed7275 100644 --- a/src/tools/mod.rs +++ b/src/tools/mod.rs @@ -13,7 +13,6 @@ use proxmox_http::{ }; pub mod apt; -pub mod async_io; pub mod config; pub mod disks; -- 2.30.2