public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends
@ 2021-01-12 13:58 Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 1/4] Cargo.toml: update to tokio 1.0 Fabian Grünbichler
                   ` (20 more replies)
  0 siblings, 21 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

this series updates to tokio 1.0 and related crates:
- bytes 1
- openssl 0.10
- tokio-openssl 0.6.1
- hyper 0.14
- h2 0.3
- tokio-stream (new, split out)
- tokio-util 0.6
- rustyline 7
- pin-project 1
- nix 0.19.1
- crossbeam-channel 0.5

the main changes are:
- mio no longer exposed by tokio, PollEvented is replaced by AsyncFd
- tokio runtime setup / interface was adapted
- tokio Stream code got split into a separate crate until std::stream exists
- tokio::io::AsyncRead using ReadBuf
- tokio::time::{Sleep,Timeout} no longer Unpin and renamed (delay -> sleep)
- tokio-openssl API changed
- hyper HTTP2 upgrade API changed

the recently introduced TimeoutFutureExt from the proxmox crate is dropped in
favour of using tokio::time::timeout directly, since it only had three call
sites.

the unused futures-io feature (and related code) in pxar was dropped.

all the important Stream wrappers/adapters now exist in tokio-stream.

AFAICT no performance regression or otherwise (anymore)

proxmox:
 proxmox/Cargo.toml              | 13 +++++----
 proxmox/debian/control          | 61 +++++++++++++++++++++++++++--------------
 proxmox/src/api/cli/readline.rs |  4 ++-
 proxmox/src/tools/future.rs     | 48 --------------------------------
 proxmox/src/tools/mod.rs        |  1 -
 proxmox/src/tools/websocket.rs  | 18 ++++++------
 6 files changed, 59 insertions(+), 86 deletions(-)

proxmox-backup:
 Cargo.toml                             | 25 +++++++------
 debian/control                         | 49 ++++++++++++-------------
 examples/h2client.rs                   | 37 ++++++++++---------
 examples/h2s-client.rs                 | 67 ++++++++++++++++------------------
 examples/h2s-server.rs                 | 42 ++++++++++-----------
 examples/h2server.rs                   | 56 +++++++++++++++-------------
 src/api2/admin/datastore.rs            |  3 +-
 src/api2/backup.rs                     |  5 +--
 src/api2/node.rs                       | 14 +++----
 src/api2/reader.rs                     |  5 +--
 src/backup/async_index_reader.rs       | 23 ++++++------
 src/bin/proxmox-backup-client.rs       |  5 ++-
 src/bin/proxmox-backup-manager.rs      |  2 +-
 src/bin/proxmox-backup-proxy.rs        | 38 ++++++++++++++-----
 src/bin/proxmox-daily-update.rs        |  2 +-
 src/bin/proxmox-tape.rs                |  2 +-
 src/bin/proxmox_backup_client/mount.rs |  5 ++-
 src/client/backup_writer.rs            | 10 ++---
 src/client/http_client.rs              | 40 +++++++++++---------
 src/server/command_socket.rs           |  2 +-
 src/server/rest.rs                     | 12 +++---
 src/tools/async_channel_writer.rs      |  2 +-
 src/tools/async_io.rs                  | 52 ++------------------------
 src/tools/broadcast_future.rs          |  2 +-
 src/tools/daemon.rs                    |  8 ++--
 src/tools/http.rs                      | 11 +++---
 src/tools/runtime.rs                   |  6 +--
 src/tools/wrapped_reader_stream.rs     |  8 ++--
 src/tools/zip.rs                       |  1 -
 tests/worker-task-abort.rs             |  2 +-
 30 files changed, 255 insertions(+), 281 deletions(-)

proxmox-backup-qemu:
 Cargo.toml     | 14 ++++++++------
 src/backup.rs  |  9 ++++-----
 src/restore.rs |  9 ++++-----
 3 files changed, 16 insertions(+), 16 deletions(-)

proxmox-fuse:
 Cargo.toml     |  7 +++++--
 debian/control | 22 ++++++++++------------
 src/fuse_fd.rs | 30 ------------------------------
 src/session.rs | 14 ++++++--------
 4 files changed, 21 insertions(+), 52 deletions(-)

pxar:
 Cargo.toml          |  11 ++---
 debian/control      |  78 +++++++++--------------------
 src/accessor/aio.rs |  41 ++++------------
 src/decoder/aio.rs  | 139 ++++++++--------------------------------------------
 src/encoder/aio.rs  |  81 ------------------------------
 src/encoder/mod.rs  |  21 ++------
 src/lib.rs          |  25 ++--------
 src/util.rs         |   7 +--
 8 files changed, 67 insertions(+), 336 deletions(-)





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox 1/4] Cargo.toml: update to tokio 1.0
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 2/4] update to rustyline 7 Fabian Grünbichler
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 proxmox/Cargo.toml     | 13 ++++-----
 proxmox/debian/control | 61 ++++++++++++++++++++++++++++--------------
 2 files changed, 48 insertions(+), 26 deletions(-)

diff --git a/proxmox/Cargo.toml b/proxmox/Cargo.toml
index b3d6030..46037b9 100644
--- a/proxmox/Cargo.toml
+++ b/proxmox/Cargo.toml
@@ -13,14 +13,14 @@ exclude = [ "debian" ]
 
 [[example]]
 name = "u2ftest"
-required-features = [ "tokio", "u2f" ]
+required-features = [ "tokio", "tokio-stream", "u2f" ]
 
 [dependencies]
 # General dependencies
 anyhow = "1.0"
 lazy_static = "1.4"
 libc = "0.2"
-nix = "0.19"
+nix = "0.19.1"
 
 # tools module:
 base32 = { version = "0.4", optional = true }
@@ -36,16 +36,17 @@ serde_json = "1.0"
 # libc, nix, lazy_static
 
 # api module:
-bytes = "0.5"
+bytes = "1.0"
 futures = { version = "0.3", optional = true }
 http = "0.2"
-hyper = { version = "0.13", optional = true }
+hyper = { version = "0.14", features = [ "full" ], optional = true }
 percent-encoding = "2.1"
 openssl =  { version = "0.10", optional = true }
-rustyline = "6"
+rustyline = "7"
 serde_derive = "1.0"
 textwrap = "0.11"
-tokio = { version = "0.2", features = [], optional = true }
+tokio = { version = "1.0", features = [], optional = true }
+tokio-stream = { version = "0.1.1", optional = true }
 url = "2.1"
 #regex, serde, serde_json
 
diff --git a/proxmox/debian/control b/proxmox/debian/control
index 47226da..feac20c 100644
--- a/proxmox/debian/control
+++ b/proxmox/debian/control
@@ -9,27 +9,28 @@ Build-Depends: debhelper (>= 11),
  librust-anyhow-1+default-dev <!nocheck>,
  librust-base32-0.4+default-dev <!nocheck>,
  librust-base64-0.12+default-dev <!nocheck>,
- librust-bytes-0.5+default-dev <!nocheck>,
+ librust-bytes-1+default-dev <!nocheck>,
  librust-endian-trait-0.6+arrays-dev <!nocheck>,
  librust-endian-trait-0.6+default-dev <!nocheck>,
  librust-futures-0.3+default-dev <!nocheck>,
  librust-http-0.2+default-dev <!nocheck>,
- librust-hyper-0.13+default-dev <!nocheck>,
+ librust-hyper-0.14+default-dev <!nocheck>,
+ librust-hyper-0.14+full-dev <!nocheck>,
  librust-lazy-static-1+default-dev (>= 1.4-~~) <!nocheck>,
  librust-libc-0.2+default-dev <!nocheck>,
- librust-nix-0.19+default-dev <!nocheck>,
+ librust-nix-0.19+default-dev (>= 0.19.1-~~) <!nocheck>,
  librust-openssl-0.10+default-dev <!nocheck>,
  librust-percent-encoding-2+default-dev (>= 2.1-~~) <!nocheck>,
  librust-regex-1+default-dev (>= 1.2-~~) <!nocheck>,
- librust-rustyline-6+default-dev <!nocheck>,
+ librust-rustyline-7+default-dev <!nocheck>,
  librust-serde-1+default-dev <!nocheck>,
  librust-serde-1+derive-dev <!nocheck>,
  librust-serde-derive-1+default-dev <!nocheck>,
  librust-serde-json-1+default-dev <!nocheck>,
  librust-textwrap-0.11+default-dev <!nocheck>,
- librust-tokio-0.2+default-dev <!nocheck>,
- librust-tokio-0.2+io-util-dev <!nocheck>,
- librust-tokio-0.2+sync-dev <!nocheck>,
+ librust-tokio-1+default-dev <!nocheck>,
+ librust-tokio-1+io-util-dev <!nocheck>,
+ librust-tokio-1+sync-dev <!nocheck>,
  librust-url-2+default-dev (>= 2.1-~~) <!nocheck>,
  uuid-dev <!nocheck>,
  uuid-dev <!nocheck>,
@@ -50,16 +51,16 @@ Depends:
  ${misc:Depends},
  librust-anyhow-1+default-dev,
  librust-base64-0.12+default-dev,
- librust-bytes-0.5+default-dev,
+ librust-bytes-1+default-dev,
  librust-endian-trait-0.6+arrays-dev,
  librust-endian-trait-0.6+default-dev,
  librust-http-0.2+default-dev,
  librust-lazy-static-1+default-dev (>= 1.4-~~),
  librust-libc-0.2+default-dev,
- librust-nix-0.19+default-dev,
+ librust-nix-0.19+default-dev (>= 0.19.1-~~),
  librust-percent-encoding-2+default-dev (>= 2.1-~~),
  librust-regex-1+default-dev (>= 1.2-~~),
- librust-rustyline-6+default-dev,
+ librust-rustyline-7+default-dev,
  librust-serde-1+default-dev,
  librust-serde-1+derive-dev,
  librust-serde-derive-1+default-dev,
@@ -80,6 +81,7 @@ Suggests:
  librust-proxmox+proxmox-sortable-macro-dev (= ${binary:Version}),
  librust-proxmox+router-dev (= ${binary:Version}),
  librust-proxmox+tokio-dev (= ${binary:Version}),
+ librust-proxmox+tokio-stream-dev (= ${binary:Version}),
  librust-proxmox+websocket-dev (= ${binary:Version})
 Provides:
  librust-proxmox+test-harness-dev (= ${binary:Version}),
@@ -142,8 +144,9 @@ Depends:
  ${misc:Depends},
  librust-proxmox-dev (= ${binary:Version}),
  librust-proxmox+router-dev (= ${binary:Version}),
- librust-hyper-0.13+default-dev,
- librust-tokio-0.2+default-dev
+ librust-hyper-0.14+default-dev,
+ librust-hyper-0.14+full-dev,
+ librust-tokio-1+default-dev
 Provides:
  librust-proxmox-0+cli-dev (= ${binary:Version}),
  librust-proxmox-0.9+cli-dev (= ${binary:Version}),
@@ -178,7 +181,7 @@ Depends:
  ${misc:Depends},
  librust-proxmox-dev (= ${binary:Version}),
  librust-proxmox+u2f-dev (= ${binary:Version}),
- librust-tokio-0.2+macros-dev
+ librust-tokio-1+macros-dev
 Provides:
  librust-proxmox-0+examples-dev (= ${binary:Version}),
  librust-proxmox-0.9+examples-dev (= ${binary:Version}),
@@ -208,7 +211,8 @@ Multi-Arch: same
 Depends:
  ${misc:Depends},
  librust-proxmox-dev (= ${binary:Version}),
- librust-hyper-0.13+default-dev
+ librust-hyper-0.14+default-dev,
+ librust-hyper-0.14+full-dev
 Provides:
  librust-proxmox-0+hyper-dev (= ${binary:Version}),
  librust-proxmox-0.9+hyper-dev (= ${binary:Version}),
@@ -265,8 +269,9 @@ Multi-Arch: same
 Depends:
  ${misc:Depends},
  librust-proxmox-dev (= ${binary:Version}),
- librust-hyper-0.13+default-dev,
- librust-tokio-0.2+default-dev
+ librust-hyper-0.14+default-dev,
+ librust-hyper-0.14+full-dev,
+ librust-tokio-1+default-dev
 Provides:
  librust-proxmox-0+router-dev (= ${binary:Version}),
  librust-proxmox-0.9+router-dev (= ${binary:Version}),
@@ -281,7 +286,7 @@ Multi-Arch: same
 Depends:
  ${misc:Depends},
  librust-proxmox-dev (= ${binary:Version}),
- librust-tokio-0.2+default-dev
+ librust-tokio-1+default-dev
 Provides:
  librust-proxmox-0+tokio-dev (= ${binary:Version}),
  librust-proxmox-0.9+tokio-dev (= ${binary:Version}),
@@ -290,6 +295,21 @@ Description: Proxmox library - feature "tokio"
  This metapackage enables feature "tokio" for the Rust proxmox crate, by pulling
  in any additional dependencies needed by that feature.
 
+Package: librust-proxmox+tokio-stream-dev
+Architecture: any
+Multi-Arch: same
+Depends:
+ ${misc:Depends},
+ librust-proxmox-dev (= ${binary:Version}),
+ librust-tokio-stream-0.1+default-dev (>= 0.1.1-~~)
+Provides:
+ librust-proxmox-0+tokio-stream-dev (= ${binary:Version}),
+ librust-proxmox-0.9+tokio-stream-dev (= ${binary:Version}),
+ librust-proxmox-0.9.1+tokio-stream-dev (= ${binary:Version})
+Description: Proxmox library - feature "tokio-stream"
+ This metapackage enables feature "tokio-stream" for the Rust proxmox crate, by
+ pulling in any additional dependencies needed by that feature.
+
 Package: librust-proxmox+websocket-dev
 Architecture: any
 Multi-Arch: same
@@ -297,10 +317,11 @@ Depends:
  ${misc:Depends},
  librust-proxmox-dev (= ${binary:Version}),
  librust-futures-0.3+default-dev,
- librust-hyper-0.13+default-dev,
+ librust-hyper-0.14+default-dev,
+ librust-hyper-0.14+full-dev,
  librust-openssl-0.10+default-dev,
- librust-tokio-0.2+io-util-dev,
- librust-tokio-0.2+sync-dev
+ librust-tokio-1+io-util-dev,
+ librust-tokio-1+sync-dev
 Provides:
  librust-proxmox-0+websocket-dev (= ${binary:Version}),
  librust-proxmox-0.9+websocket-dev (= ${binary:Version}),
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox 2/4] update to rustyline 7
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 1/4] Cargo.toml: update to tokio 1.0 Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 3/4] update to tokio 1.0 Fabian Grünbichler
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 proxmox/src/api/cli/readline.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/proxmox/src/api/cli/readline.rs b/proxmox/src/api/cli/readline.rs
index 4d617c9..d35f1cb 100644
--- a/proxmox/src/api/cli/readline.rs
+++ b/proxmox/src/api/cli/readline.rs
@@ -40,7 +40,9 @@ impl rustyline::completion::Completer for CliHelper {
     }
 }
 
-impl rustyline::hint::Hinter for CliHelper {}
+impl rustyline::hint::Hinter for CliHelper {
+    type Hint = String;
+}
 impl rustyline::validate::Validator for CliHelper {}
 impl rustyline::highlight::Highlighter for CliHelper {}
 impl rustyline::Helper for CliHelper {}
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox 3/4] update to tokio 1.0
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 1/4] Cargo.toml: update to tokio 1.0 Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 2/4] update to rustyline 7 Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 4/4] tokio 1.0: drop TimeoutFutureExt Fabian Grünbichler
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 proxmox/src/tools/websocket.rs | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/proxmox/src/tools/websocket.rs b/proxmox/src/tools/websocket.rs
index f1cefd6..1d90bd2 100644
--- a/proxmox/src/tools/websocket.rs
+++ b/proxmox/src/tools/websocket.rs
@@ -16,7 +16,7 @@ use hyper::header::{
     SEC_WEBSOCKET_PROTOCOL, SEC_WEBSOCKET_VERSION, UPGRADE,
 };
 use hyper::{Body, Response, StatusCode};
-use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
+use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf};
 use tokio::sync::mpsc;
 
 use futures::future::FutureExt;
@@ -528,10 +528,9 @@ impl<R: AsyncReadExt + Unpin + Send + 'static> AsyncRead for WebSocketReader<R>
     fn poll_read(
         self: Pin<&mut Self>,
         cx: &mut Context,
-        buf: &mut [u8],
-    ) -> Poll<io::Result<usize>> {
+        buf: &mut ReadBuf,
+    ) -> Poll<io::Result<()>> {
         let this = Pin::get_mut(self);
-        let mut offset = 0;
 
         loop {
             match &mut this.state {
@@ -569,7 +568,7 @@ impl<R: AsyncReadExt + Unpin + Send + 'static> AsyncRead for WebSocketReader<R>
                         this.read_buffer = Some(buffer);
                         this.state = ReaderState::HaveData;
                         if len == 0 {
-                            return Poll::Ready(Ok(0));
+                            return Poll::Ready(Ok(()));
                         }
                     }
                     Err(err) => return Poll::Ready(Err(err)),
@@ -627,14 +626,13 @@ impl<R: AsyncReadExt + Unpin + Send + 'static> AsyncRead for WebSocketReader<R>
                     }
 
                     let len = min(
-                        buf.len() - offset,
+                        buf.remaining(),
                         min(header.payload_len, read_buffer.len()),
                     );
 
                     let mut data = read_buffer.remove_data(len);
                     mask_bytes(header.mask, &mut data);
-                    buf[offset..offset + len].copy_from_slice(&data);
-                    offset += len;
+                    buf.put_slice(&data);
 
                     header.payload_len -= len;
 
@@ -649,8 +647,8 @@ impl<R: AsyncReadExt + Unpin + Send + 'static> AsyncRead for WebSocketReader<R>
                     };
                     this.read_buffer = Some(read_buffer);
 
-                    if offset > 0 {
-                        return Poll::Ready(Ok(offset));
+                    if len > 0 {
+                        return Poll::Ready(Ok(()));
                     }
                 }
             }
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox 4/4] tokio 1.0: drop TimeoutFutureExt
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (2 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 3/4] update to tokio 1.0 Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 01/12] update to tokio 1.0 Fabian Grünbichler
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

tokio's Sleep/Delay/Timeout are no longer Unpin, complicating this
wrapper. we can just use tokio::time::timeout directly as needed..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 proxmox/src/tools/future.rs | 48 -------------------------------------
 proxmox/src/tools/mod.rs    |  1 -
 2 files changed, 49 deletions(-)
 delete mode 100644 proxmox/src/tools/future.rs

diff --git a/proxmox/src/tools/future.rs b/proxmox/src/tools/future.rs
deleted file mode 100644
index cf9fae7..0000000
--- a/proxmox/src/tools/future.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-//! Common extensions for Futures
-use anyhow::Error;
-use futures::future::{select, Either, FutureExt};
-use std::future::Future;
-use std::time::Duration;
-use tokio::time::delay_for;
-
-impl<T> TimeoutFutureExt for T where T: Future {}
-
-/// Implements a timeout for futures, automatically aborting them if the timeout runs out before
-/// the base future completes.
-pub trait TimeoutFutureExt: Future {
-    /// Returned Future returns 'None' in case the timeout was reached, otherwise the original
-    /// return value.
-    fn or_timeout<'a>(
-        self,
-        timeout: Duration,
-    ) -> Box<dyn Future<Output = Option<Self::Output>> + Unpin + Send + 'a>
-    where
-        Self: Sized + Unpin + Send + 'a,
-    {
-        let timeout_fut = delay_for(timeout);
-        Box::new(select(self, timeout_fut).map(|res| match res {
-            Either::Left((result, _)) => Some(result),
-            Either::Right(((), _)) => None,
-        }))
-    }
-
-    /// Returned Future returns either the original result, or `Err<err>` in case the timeout is
-    /// reached. Basically a shorthand to flatten a future that returns a `Result<_, Error>` with a
-    /// timeout. The base Future can return any kind of Error that can be made into an
-    /// `anyhow::Error`.
-    fn or_timeout_err<'a, O, E>(
-        self,
-        timeout: Duration,
-        err: Error,
-    ) -> Box<dyn Future<Output = Result<O, Error>> + Unpin + Send + 'a>
-    where
-        Self: Sized + Unpin + Send + 'a,
-        Self::Output: Into<Result<O, E>>,
-        E: Into<Error> + std::error::Error + Send + Sync + 'static,
-    {
-        Box::new(self.or_timeout(timeout).map(|res| match res {
-            Some(res) => res.into().map_err(Error::from),
-            None => Err(err),
-        }))
-    }
-}
diff --git a/proxmox/src/tools/mod.rs b/proxmox/src/tools/mod.rs
index 5d1f46e..ff3a720 100644
--- a/proxmox/src/tools/mod.rs
+++ b/proxmox/src/tools/mod.rs
@@ -20,7 +20,6 @@ pub mod serde;
 pub mod time;
 pub mod uuid;
 pub mod vec;
-pub mod future;
 
 #[cfg(feature = "websocket")]
 pub mod websocket;
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 01/12] update to tokio 1.0
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (3 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 4/4] tokio 1.0: drop TimeoutFutureExt Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 02/12] tokio 1.0: delay -> sleep Fabian Grünbichler
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

and various related crates

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 Cargo.toml       | 25 ++++++++++++------------
 debian/control   | 49 ++++++++++++++++++++++++------------------------
 src/tools/zip.rs |  1 -
 3 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 0fc4d317..01fd0e96 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,19 +26,19 @@ path = "src/lib.rs"
 apt-pkg-native = "0.3.1" # custom patched version
 base64 = "0.12"
 bitflags = "1.2.1"
-bytes = "0.5"
+bytes = "1.0"
 crc32fast = "1"
 endian_trait = { version = "0.6", features = ["arrays"] }
 anyhow = "1.0"
 futures = "0.3"
-h2 = { version = "0.2", features = ["stream"] }
+h2 = { version = "0.3", features = [ "stream" ] }
 handlebars = "3.0"
 http = "0.2"
-hyper = "0.13.6"
+hyper = { version = "0.14", features = [ "full" ] }
 lazy_static = "1.4"
 libc = "0.2"
 log = "0.4"
-nix = "0.19"
+nix = "0.19.1"
 num-traits = "0.2"
 once_cell = "1.3.1"
 openssl = "0.10"
@@ -46,23 +46,24 @@ pam = "0.7"
 pam-sys = "0.5"
 percent-encoding = "2.1"
 pin-utils = "0.1.0"
-pin-project = "0.4"
+pin-project = "1.0"
 pathpatterns = "0.1.2"
 proxmox = { version = "0.9.1", features = [ "sortable-macro", "api-macro", "websocket" ] }
 #proxmox = { git = "git://git.proxmox.com/git/proxmox", version = "0.1.2", features = [ "sortable-macro", "api-macro" ] }
 #proxmox = { path = "../proxmox/proxmox", features = [ "sortable-macro", "api-macro", "websocket" ] }
 proxmox-fuse = "0.1.0"
-pxar = { version = "0.6.2", features = [ "tokio-io", "futures-io" ] }
-#pxar = { path = "../pxar", features = [ "tokio-io", "futures-io" ] }
+pxar = { version = "0.6.2", features = [ "tokio-io" ] }
+#pxar = { path = "../pxar", features = [ "tokio-io" ] }
 regex = "1.2"
-rustyline = "6"
+rustyline = "7"
 serde = { version = "1.0", features = ["derive"] }
 serde_json = "1.0"
 siphasher = "0.3"
 syslog = "4.0"
-tokio = { version = "0.2.9", features = [ "blocking", "fs", "dns", "io-util", "macros", "process", "rt-threaded", "signal", "stream", "tcp", "time", "uds" ] }
-tokio-openssl = "0.4.0"
-tokio-util = { version = "0.3", features = [ "codec" ] }
+tokio = { version = "1.0", features = [ "fs", "io-util", "macros", "net", "parking_lot", "process", "rt", "rt-multi-thread", "signal", "time" ] }
+tokio-openssl = "0.6.1"
+tokio-stream = "0.1.0"
+tokio-util = { version = "0.6", features = [ "codec" ] }
 tower-service = "0.3.0"
 udev = ">= 0.3, <0.5"
 url = "2.1"
@@ -72,7 +73,7 @@ webauthn-rs = "0.2.5"
 xdg = "2.2"
 zstd = { version = "0.4", features = [ "bindgen" ] }
 nom = "5.1"
-crossbeam-channel = "0.4"
+crossbeam-channel = "0.5"
 
 [features]
 default = []
diff --git a/debian/control b/debian/control
index 275acf35..6903155b 100644
--- a/debian/control
+++ b/debian/control
@@ -10,21 +10,22 @@ Build-Depends: debhelper (>= 11),
  librust-apt-pkg-native-0.3+default-dev (>= 0.3.1-~~),
  librust-base64-0.12+default-dev,
  librust-bitflags-1+default-dev (>= 1.2.1-~~),
- librust-bytes-0.5+default-dev,
+ librust-bytes-1+default-dev,
  librust-crc32fast-1+default-dev,
- librust-crossbeam-channel-0.4+default-dev,
+ librust-crossbeam-channel-0.5+default-dev,
  librust-endian-trait-0.6+arrays-dev,
  librust-endian-trait-0.6+default-dev,
  librust-futures-0.3+default-dev,
- librust-h2-0.2+default-dev,
- librust-h2-0.2+stream-dev,
+ librust-h2-0.3+default-dev,
+ librust-h2-0.3+stream-dev,
  librust-handlebars-3+default-dev,
  librust-http-0.2+default-dev,
- librust-hyper-0.13+default-dev (>= 0.13.6-~~),
+ librust-hyper-0.14+default-dev,
+ librust-hyper-0.14+full-dev,
  librust-lazy-static-1+default-dev (>= 1.4-~~),
  librust-libc-0.2+default-dev,
  librust-log-0.4+default-dev,
- librust-nix-0.19+default-dev,
+ librust-nix-0.19+default-dev (>= 0.19.1-~~),
  librust-nom-5+default-dev (>= 5.1-~~),
  librust-num-traits-0.2+default-dev,
  librust-once-cell-1+default-dev (>= 1.3.1-~~),
@@ -33,7 +34,7 @@ Build-Depends: debhelper (>= 11),
  librust-pam-sys-0.5+default-dev,
  librust-pathpatterns-0.1+default-dev (>= 0.1.2-~~),
  librust-percent-encoding-2+default-dev (>= 2.1-~~),
- librust-pin-project-0.4+default-dev,
+ librust-pin-project-1+default-dev,
  librust-pin-utils-0.1+default-dev,
  librust-proxmox-0.9+api-macro-dev (>= 0.9.1-~~),
  librust-proxmox-0.9+default-dev (>= 0.9.1-~~),
@@ -41,31 +42,29 @@ Build-Depends: debhelper (>= 11),
  librust-proxmox-0.9+websocket-dev (>= 0.9.1-~~),
  librust-proxmox-fuse-0.1+default-dev,
  librust-pxar-0.6+default-dev (>= 0.6.2-~~),
- librust-pxar-0.6+futures-io-dev (>= 0.6.2-~~),
  librust-pxar-0.6+tokio-io-dev (>= 0.6.2-~~),
  librust-regex-1+default-dev (>= 1.2-~~),
- librust-rustyline-6+default-dev,
+ librust-rustyline-7+default-dev,
  librust-serde-1+default-dev,
  librust-serde-1+derive-dev,
  librust-serde-json-1+default-dev,
  librust-siphasher-0.3+default-dev,
  librust-syslog-4+default-dev,
- librust-tokio-0.2+blocking-dev (>= 0.2.9-~~),
- librust-tokio-0.2+default-dev (>= 0.2.9-~~),
- librust-tokio-0.2+dns-dev (>= 0.2.9-~~),
- librust-tokio-0.2+fs-dev (>= 0.2.9-~~),
- librust-tokio-0.2+io-util-dev (>= 0.2.9-~~),
- librust-tokio-0.2+macros-dev (>= 0.2.9-~~),
- librust-tokio-0.2+process-dev (>= 0.2.9-~~),
- librust-tokio-0.2+rt-threaded-dev (>= 0.2.9-~~),
- librust-tokio-0.2+signal-dev (>= 0.2.9-~~),
- librust-tokio-0.2+stream-dev (>= 0.2.9-~~),
- librust-tokio-0.2+tcp-dev (>= 0.2.9-~~),
- librust-tokio-0.2+time-dev (>= 0.2.9-~~),
- librust-tokio-0.2+uds-dev (>= 0.2.9-~~),
- librust-tokio-openssl-0.4+default-dev,
- librust-tokio-util-0.3+codec-dev,
- librust-tokio-util-0.3+default-dev,
+ librust-tokio-1+default-dev,
+ librust-tokio-1+fs-dev,
+ librust-tokio-1+io-util-dev,
+ librust-tokio-1+macros-dev,
+ librust-tokio-1+net-dev,
+ librust-tokio-1+parking-lot-dev,
+ librust-tokio-1+process-dev,
+ librust-tokio-1+rt-dev,
+ librust-tokio-1+rt-multi-thread-dev,
+ librust-tokio-1+signal-dev,
+ librust-tokio-1+time-dev,
+ librust-tokio-openssl-0.6+default-dev (>= 0.6.1-~~),
+ librust-tokio-stream-0.1+default-dev,
+ librust-tokio-util-0.6+codec-dev,
+ librust-tokio-util-0.6+default-dev,
  librust-tower-service-0.3+default-dev,
  librust-udev-0.4+default-dev | librust-udev-0.3+default-dev,
  librust-url-2+default-dev (>= 2.1-~~),
diff --git a/src/tools/zip.rs b/src/tools/zip.rs
index d651b092..1f9ee517 100644
--- a/src/tools/zip.rs
+++ b/src/tools/zip.rs
@@ -354,7 +354,6 @@ impl ZipEntry {
 /// ```no_run
 /// use proxmox_backup::tools::zip::*;
 /// use tokio::fs::File;
-/// use tokio::prelude::*;
 /// use anyhow::{Error, Result};
 ///
 /// #[tokio::main]
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 02/12] tokio 1.0: delay -> sleep
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (4 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 01/12] update to tokio 1.0 Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 03/12] proxmox XXX: use tokio::time::timeout directly Fabian Grünbichler
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

almost the same thing, new name(s), no longer Unpin

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/bin/proxmox-backup-manager.rs | 2 +-
 src/bin/proxmox-backup-proxy.rs   | 6 +++---
 src/bin/proxmox-daily-update.rs   | 2 +-
 src/bin/proxmox-tape.rs           | 2 +-
 src/client/http_client.rs         | 2 +-
 src/server/rest.rs                | 8 ++++----
 src/tools/daemon.rs               | 8 ++++----
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-manager.rs
index ff2a1dc1..c114079a 100644
--- a/src/bin/proxmox-backup-manager.rs
+++ b/src/bin/proxmox-backup-manager.rs
@@ -41,7 +41,7 @@ pub async fn wait_for_local_worker(upid_str: &str) -> Result<(), Error> {
 
     loop {
         if proxmox_backup::server::worker_is_active_local(&upid) {
-            tokio::time::delay_for(sleep_duration).await;
+            tokio::time::sleep(sleep_duration).await;
         } else {
             break;
         }
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index 6414d646..2228253d 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -262,7 +262,7 @@ async fn run_task_scheduler() {
             Ok(d) => d,
             Err(err) => {
                 eprintln!("task scheduler: compute next minute failed - {}", err);
-                tokio::time::delay_until(tokio::time::Instant::from_std(Instant::now() + Duration::from_secs(60))).await;
+                tokio::time::sleep_until(tokio::time::Instant::from_std(Instant::now() + Duration::from_secs(60))).await;
                 continue;
             }
         };
@@ -286,7 +286,7 @@ async fn run_task_scheduler() {
             }
         }
 
-        tokio::time::delay_until(tokio::time::Instant::from_std(delay_target)).await;
+        tokio::time::sleep_until(tokio::time::Instant::from_std(delay_target)).await;
     }
 }
 
@@ -649,7 +649,7 @@ async fn run_stat_generator() {
 
         generate_host_stats(save).await;
 
-        tokio::time::delay_until(tokio::time::Instant::from_std(delay_target)).await;
+        tokio::time::sleep_until(tokio::time::Instant::from_std(delay_target)).await;
 
      }
 
diff --git a/src/bin/proxmox-daily-update.rs b/src/bin/proxmox-daily-update.rs
index b78d1643..99f5152e 100644
--- a/src/bin/proxmox-daily-update.rs
+++ b/src/bin/proxmox-daily-update.rs
@@ -14,7 +14,7 @@ async fn wait_for_local_worker(upid_str: &str) -> Result<(), Error> {
         if !proxmox_backup::server::worker_is_active_local(&upid) {
             break;
         }
-        tokio::time::delay_for(sleep_duration).await;
+        tokio::time::sleep(sleep_duration).await;
     }
     Ok(())
 }
diff --git a/src/bin/proxmox-tape.rs b/src/bin/proxmox-tape.rs
index 4850008a..d9a84060 100644
--- a/src/bin/proxmox-tape.rs
+++ b/src/bin/proxmox-tape.rs
@@ -65,7 +65,7 @@ pub async fn wait_for_local_worker(upid_str: &str) -> Result<(), Error> {
 
     loop {
         if worker_is_active_local(&upid) {
-            tokio::time::delay_for(sleep_duration).await;
+            tokio::time::sleep(sleep_duration).await;
         } else {
             break;
         }
diff --git a/src/client/http_client.rs b/src/client/http_client.rs
index 92df9572..7febbe51 100644
--- a/src/client/http_client.rs
+++ b/src/client/http_client.rs
@@ -345,7 +345,7 @@ impl HttpClient {
 
         let renewal_future = async move {
             loop {
-                tokio::time::delay_for(Duration::new(60*15,  0)).await; // 15 minutes
+                tokio::time::sleep(Duration::new(60*15,  0)).await; // 15 minutes
                 let (auth_id, ticket) = {
                     let authinfo = auth2.read().unwrap().clone();
                     (authinfo.auth_id, authinfo.ticket)
diff --git a/src/server/rest.rs b/src/server/rest.rs
index 307f888e..04bdc5f9 100644
--- a/src/server/rest.rs
+++ b/src/server/rest.rs
@@ -385,7 +385,7 @@ pub async fn handle_api_request<Env: RpcEnvironment, S: 'static + BuildHasher +
         Err(err) => {
             if let Some(httperr) = err.downcast_ref::<HttpError>() {
                 if httperr.code == StatusCode::UNAUTHORIZED {
-                    tokio::time::delay_until(Instant::from_std(delay_unauth_time)).await;
+                    tokio::time::sleep_until(Instant::from_std(delay_unauth_time)).await;
                 }
             }
             (formatter.format_error)(err)
@@ -708,7 +708,7 @@ async fn handle_request(
 
                         // always delay unauthorized calls by 3 seconds (from start of request)
                         let err = http_err!(UNAUTHORIZED, "authentication failed - {}", err);
-                        tokio::time::delay_until(Instant::from_std(delay_unauth_time)).await;
+                        tokio::time::sleep_until(Instant::from_std(delay_unauth_time)).await;
                         return Ok((formatter.format_error)(err));
                     }
                 }
@@ -723,7 +723,7 @@ async fn handle_request(
                     let auth_id = rpcenv.get_auth_id();
                     if !check_api_permission(api_method.access.permission, auth_id.as_deref(), &uri_param, user_info.as_ref()) {
                         let err = http_err!(FORBIDDEN, "permission check failed");
-                        tokio::time::delay_until(Instant::from_std(access_forbidden_time)).await;
+                        tokio::time::sleep_until(Instant::from_std(access_forbidden_time)).await;
                         return Ok((formatter.format_error)(err));
                     }
 
@@ -765,7 +765,7 @@ async fn handle_request(
                         return Ok(get_index(Some(userid.clone()), Some(new_csrf_token), language, &api, parts));
                     },
                     _ => {
-                        tokio::time::delay_until(Instant::from_std(delay_unauth_time)).await;
+                        tokio::time::sleep_until(Instant::from_std(delay_unauth_time)).await;
                         return Ok(get_index(None, None, language, &api, parts));
                     }
                 }
diff --git a/src/tools/daemon.rs b/src/tools/daemon.rs
index 0e3a174a..d298bf16 100644
--- a/src/tools/daemon.rs
+++ b/src/tools/daemon.rs
@@ -331,17 +331,17 @@ async fn get_service_state(service: &str) -> Result<String, Error> {
 }
 
 async fn wait_service_is_state(service: &str, state: &str) -> Result<(), Error> {
-    tokio::time::delay_for(std::time::Duration::new(1, 0)).await;
+    tokio::time::sleep(std::time::Duration::new(1, 0)).await;
     while get_service_state(service).await? != state {
-        tokio::time::delay_for(std::time::Duration::new(5, 0)).await;
+        tokio::time::sleep(std::time::Duration::new(5, 0)).await;
     }
     Ok(())
 }
 
 async fn wait_service_is_not_state(service: &str, state: &str) -> Result<(), Error> {
-    tokio::time::delay_for(std::time::Duration::new(1, 0)).await;
+    tokio::time::sleep(std::time::Duration::new(1, 0)).await;
     while get_service_state(service).await? == state {
-        tokio::time::delay_for(std::time::Duration::new(5, 0)).await;
+        tokio::time::sleep(std::time::Duration::new(5, 0)).await;
     }
     Ok(())
 }
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 03/12] proxmox XXX: use tokio::time::timeout directly
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (5 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 02/12] tokio 1.0: delay -> sleep Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 04/12] tokio 1.0: AsyncRead/Seek with ReadBuf Fabian Grünbichler
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---

Notes:
    needs a bump in Cargo.toml and the proper version added to the commit title

 src/client/http_client.rs | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/client/http_client.rs b/src/client/http_client.rs
index 7febbe51..33860abf 100644
--- a/src/client/http_client.rs
+++ b/src/client/http_client.rs
@@ -18,7 +18,6 @@ use proxmox::{
     api::error::HttpError,
     sys::linux::tty,
     tools::fs::{file_get_json, replace_file, CreateOptions},
-    tools::future::TimeoutFutureExt,
 };
 
 use super::pipe_to_stream::PipeToSendStream;
@@ -562,10 +561,12 @@ impl HttpClient {
         let enc_ticket = format!("PBSAuthCookie={}", percent_encode(auth.ticket.as_bytes(), DEFAULT_ENCODE_SET));
         req.headers_mut().insert("Cookie", HeaderValue::from_str(&enc_ticket).unwrap());
 
-        let resp = client
-            .request(req)
-            .or_timeout_err(HTTP_TIMEOUT, format_err!("http download request timed out"))
-            .await?;
+        let resp = tokio::time::timeout(
+            HTTP_TIMEOUT,
+            client.request(req)
+        )
+            .await
+            .map_err(|_| format_err!("http download request timed out"))??;
         let status = resp.status();
         if !status.is_success() {
             HttpClient::api_response(resp)
@@ -632,10 +633,12 @@ impl HttpClient {
 
         req.headers_mut().insert("UPGRADE", HeaderValue::from_str(&protocol_name).unwrap());
 
-        let resp = client
-            .request(req)
-            .or_timeout_err(HTTP_TIMEOUT, format_err!("http upgrade request timed out"))
-            .await?;
+        let resp = tokio::time::timeout(
+            HTTP_TIMEOUT,
+            client.request(req)
+        )
+            .await
+            .map_err(|_| format_err!("http upgrade request timed out"))??;
         let status = resp.status();
 
         if status != http::StatusCode::SWITCHING_PROTOCOLS {
@@ -715,10 +718,14 @@ impl HttpClient {
         req: Request<Body>
     ) -> Result<Value, Error> {
 
-        client.request(req)
-            .or_timeout_err(HTTP_TIMEOUT, format_err!("http request timed out"))
-            .and_then(Self::api_response)
-            .await
+        Self::api_response(
+            tokio::time::timeout(
+                HTTP_TIMEOUT,
+                client.request(req)
+            )
+                .await
+                .map_err(|_| format_err!("http request timed out"))??
+        ).await
     }
 
     // Read-only access to server property
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 04/12] tokio 1.0: AsyncRead/Seek with ReadBuf
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (6 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 03/12] proxmox XXX: use tokio::time::timeout directly Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 05/12] tokio: adapt to 1.0 runtime changes Fabian Grünbichler
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/backup/async_index_reader.rs   | 23 +++++++-------
 src/tools/async_io.rs              | 50 ++----------------------------
 src/tools/wrapped_reader_stream.rs |  8 +++--
 3 files changed, 19 insertions(+), 62 deletions(-)

diff --git a/src/backup/async_index_reader.rs b/src/backup/async_index_reader.rs
index f6a72099..2a04282c 100644
--- a/src/backup/async_index_reader.rs
+++ b/src/backup/async_index_reader.rs
@@ -6,7 +6,7 @@ use std::io::SeekFrom;
 use anyhow::Error;
 use futures::future::FutureExt;
 use futures::ready;
-use tokio::io::{AsyncRead, AsyncSeek};
+use tokio::io::{AsyncRead, AsyncSeek, ReadBuf};
 
 use proxmox::sys::error::io_err_other;
 use proxmox::io_format_err;
@@ -71,8 +71,8 @@ where
     fn poll_read(
         self: Pin<&mut Self>,
         cx: &mut Context,
-        buf: &mut [u8],
-    ) -> Poll<tokio::io::Result<usize>> {
+        buf: &mut ReadBuf,
+    ) -> Poll<tokio::io::Result<()>> {
         let this = Pin::get_mut(self);
         loop {
             match &mut this.state {
@@ -86,12 +86,12 @@ where
                     } else {
                         match this.index.chunk_from_offset(this.position) {
                             Some(res) => res,
-                            None => return Poll::Ready(Ok(0))
+                            None => return Poll::Ready(Ok(()))
                         }
                     };
 
                     if idx >= this.index.index_count() {
-                        return Poll::Ready(Ok(0));
+                        return Poll::Ready(Ok(()));
                     }
 
                     let info = this
@@ -142,13 +142,13 @@ where
                 AsyncIndexReaderState::HaveData => {
                     let offset = this.current_chunk_offset as usize;
                     let len = this.read_buffer.len();
-                    let n = if len - offset < buf.len() {
+                    let n = if len - offset < buf.remaining() {
                         len - offset
                     } else {
-                        buf.len()
+                        buf.remaining()
                     };
 
-                    buf[0..n].copy_from_slice(&this.read_buffer[offset..(offset + n)]);
+                    buf.put_slice(&this.read_buffer[offset..(offset + n)]);
                     this.position += n as u64;
 
                     if offset + n == len {
@@ -158,7 +158,7 @@ where
                         this.state = AsyncIndexReaderState::HaveData;
                     }
 
-                    return Poll::Ready(Ok(n));
+                    return Poll::Ready(Ok(()));
                 }
             }
         }
@@ -172,9 +172,8 @@ where
 {
     fn start_seek(
         self: Pin<&mut Self>,
-        _cx: &mut Context<'_>,
         pos: SeekFrom,
-    ) -> Poll<tokio::io::Result<()>> {
+    ) -> tokio::io::Result<()> {
         let this = Pin::get_mut(self);
         this.seek_to_pos = match pos {
             SeekFrom::Start(offset) => {
@@ -187,7 +186,7 @@ where
                 this.position as i64 + offset
             }
         };
-        Poll::Ready(Ok(()))
+        Ok(())
     }
 
     fn poll_complete(
diff --git a/src/tools/async_io.rs b/src/tools/async_io.rs
index 4e4107c0..3a5a6c9a 100644
--- a/src/tools/async_io.rs
+++ b/src/tools/async_io.rs
@@ -1,13 +1,12 @@
 //! Generic AsyncRead/AsyncWrite utilities.
 
 use std::io;
-use std::mem::MaybeUninit;
 use std::os::unix::io::{AsRawFd, RawFd};
 use std::pin::Pin;
 use std::task::{Context, Poll};
 
 use futures::stream::{Stream, TryStream};
-use tokio::io::{AsyncRead, AsyncWrite};
+use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
 use tokio::net::TcpListener;
 use hyper::client::connect::Connection;
 
@@ -20,8 +19,8 @@ impl<L: AsyncRead + Unpin, R: AsyncRead + Unpin> AsyncRead for EitherStream<L, R
     fn poll_read(
         self: Pin<&mut Self>,
         cx: &mut Context,
-        buf: &mut [u8],
-    ) -> Poll<Result<usize, io::Error>> {
+        buf: &mut ReadBuf,
+    ) -> Poll<Result<(), io::Error>> {
         match self.get_mut() {
             EitherStream::Left(ref mut s) => {
                 Pin::new(s).poll_read(cx, buf)
@@ -31,31 +30,6 @@ impl<L: AsyncRead + Unpin, R: AsyncRead + Unpin> AsyncRead for EitherStream<L, R
             }
         }
     }
-
-    unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [MaybeUninit<u8>]) -> bool {
-        match *self {
-            EitherStream::Left(ref s) => s.prepare_uninitialized_buffer(buf),
-            EitherStream::Right(ref s) => s.prepare_uninitialized_buffer(buf),
-        }
-    }
-
-    fn poll_read_buf<B>(
-        self: Pin<&mut Self>,
-        cx: &mut Context,
-        buf: &mut B,
-    ) -> Poll<Result<usize, io::Error>>
-    where
-        B: bytes::BufMut,
-    {
-        match self.get_mut() {
-            EitherStream::Left(ref mut s) => {
-                Pin::new(s).poll_read_buf(cx, buf)
-            }
-            EitherStream::Right(ref mut s) => {
-                Pin::new(s).poll_read_buf(cx, buf)
-            }
-        }
-    }
 }
 
 impl<L: AsyncWrite + Unpin, R: AsyncWrite + Unpin> AsyncWrite for EitherStream<L, R> {
@@ -95,24 +69,6 @@ impl<L: AsyncWrite + Unpin, R: AsyncWrite + Unpin> AsyncWrite for EitherStream<L
             }
         }
     }
-
-    fn poll_write_buf<B>(
-        self: Pin<&mut Self>,
-        cx: &mut Context,
-        buf: &mut B,
-    ) -> Poll<Result<usize, io::Error>>
-    where
-        B: bytes::Buf,
-    {
-        match self.get_mut() {
-            EitherStream::Left(ref mut s) => {
-                Pin::new(s).poll_write_buf(cx, buf)
-            }
-            EitherStream::Right(ref mut s) => {
-                Pin::new(s).poll_write_buf(cx, buf)
-            }
-        }
-    }
 }
 
 // we need this for crate::client::http_client:
diff --git a/src/tools/wrapped_reader_stream.rs b/src/tools/wrapped_reader_stream.rs
index 0294cc21..4b01b072 100644
--- a/src/tools/wrapped_reader_stream.rs
+++ b/src/tools/wrapped_reader_stream.rs
@@ -3,7 +3,7 @@ use std::pin::Pin;
 use std::task::{Context, Poll};
 use std::sync::mpsc::Receiver;
 
-use tokio::io::AsyncRead;
+use tokio::io::{AsyncRead, ReadBuf};
 use futures::ready;
 use futures::stream::Stream;
 
@@ -69,8 +69,10 @@ impl<R: AsyncRead + Unpin> Stream for AsyncReaderStream<R> {
 
     fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
         let this = self.get_mut();
-        match ready!(Pin::new(&mut this.reader).poll_read(cx, &mut this.buffer)) {
-            Ok(n) => {
+        let mut read_buf = ReadBuf::new(&mut this.buffer);
+        match ready!(Pin::new(&mut this.reader).poll_read(cx, &mut read_buf)) {
+            Ok(()) => {
+                let n = read_buf.filled().len();
                 if n == 0 {
                     // EOF
                     Poll::Ready(None)
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 05/12] tokio: adapt to 1.0 runtime changes
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (7 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 04/12] tokio 1.0: AsyncRead/Seek with ReadBuf Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 06/12] tokio: adapt to 1.0 process:Child changes Fabian Grünbichler
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

enter() now returns a guard, and the builder got revamped to make the
choice between MT and current thread explicit.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/tools/runtime.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/tools/runtime.rs b/src/tools/runtime.rs
index 1953e202..46564e76 100644
--- a/src/tools/runtime.rs
+++ b/src/tools/runtime.rs
@@ -84,8 +84,7 @@ pub fn get_runtime_with_builder<F: Fn() -> runtime::Builder>(get_builder: F) ->
 pub fn get_runtime() -> Arc<Runtime> {
 
     get_runtime_with_builder(|| {
-        let mut builder = runtime::Builder::new();
-        builder.threaded_scheduler();
+        let mut builder = runtime::Builder::new_multi_thread();
         builder.enable_all();
         builder
     })
@@ -122,7 +121,8 @@ pub fn block_on<F: Future>(fut: F) -> F::Output {
         // not a worker thread, not associated with a runtime, make sure we have a runtime (spawn
         // it on demand if necessary), then enter it
         let _guard = BlockingGuard::set();
-        get_runtime().enter(move || block_on_local_future(fut))
+        let _enter_guard = get_runtime().enter();
+        get_runtime().block_on(fut)
     }
 }
 
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 06/12] tokio: adapt to 1.0 process:Child changes
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (8 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 05/12] tokio: adapt to 1.0 runtime changes Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 07/12] tokio 1.0: use ReceiverStream from tokio-stream Fabian Grünbichler
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

Child itself is no longer a Future, but it has a new wait() async fn
that does the same thing

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/api2/node.rs | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/api2/node.rs b/src/api2/node.rs
index b1a25e0e..51dfdd19 100644
--- a/src/api2/node.rs
+++ b/src/api2/node.rs
@@ -197,7 +197,7 @@ async fn termproxy(
 
             let mut needs_kill = false;
             let res = tokio::select!{
-                res = &mut child => {
+                res = child.wait() => {
                     let exit_code = res?;
                     if !exit_code.success() {
                         match exit_code.code() {
@@ -217,14 +217,13 @@ async fn termproxy(
 
             if needs_kill {
                 if res.is_ok() {
-                    child.kill()?;
-                    child.await?;
+                    child.kill().await?;
                     return Ok(());
                 }
 
-                if let Err(err) = child.kill() {
+                if let Err(err) = child.kill().await {
                     worker.warn(format!("error killing termproxy: {}", err));
-                } else if let Err(err) = child.await {
+                } else if let Err(err) = child.wait().await {
                     worker.warn(format!("error awaiting termproxy: {}", err));
                 }
             }
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 07/12] tokio 1.0: use ReceiverStream from tokio-stream
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (9 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 06/12] tokio: adapt to 1.0 process:Child changes Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 08/12] tokio 1.0: update to new tokio-openssl interface Fabian Grünbichler
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

to wrap a Receiver in a Stream. this will likely move back into tokio
proper once we have a std Stream..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/api2/admin/datastore.rs      | 3 ++-
 src/bin/proxmox-backup-client.rs | 3 ++-
 src/bin/proxmox-backup-proxy.rs  | 3 ++-
 src/client/backup_writer.rs      | 5 +++--
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index 32352e5c..5b9a1e84 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -10,6 +10,7 @@ use futures::*;
 use hyper::http::request::Parts;
 use hyper::{header, Body, Response, StatusCode};
 use serde_json::{json, Value};
+use tokio_stream::wrappers::ReceiverStream;
 
 use proxmox::api::{
     api, ApiResponseFuture, ApiHandler, ApiMethod, Router,
@@ -1562,7 +1563,7 @@ fn pxar_file_download(
                         .map_err(|err| eprintln!("error during finishing of zip: {}", err))
                 });
 
-                Body::wrap_stream(receiver.map_err(move |err| {
+                Body::wrap_stream(ReceiverStream::new(receiver).map_err(move |err| {
                     eprintln!("error during streaming of zip '{:?}' - {}", filepath, err);
                     err
                 }))
diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs
index b8f09a4a..d91f04cc 100644
--- a/src/bin/proxmox-backup-client.rs
+++ b/src/bin/proxmox-backup-client.rs
@@ -12,6 +12,7 @@ use futures::future::FutureExt;
 use futures::stream::{StreamExt, TryStreamExt};
 use serde_json::{json, Value};
 use tokio::sync::mpsc;
+use tokio_stream::wrappers::ReceiverStream;
 use xdg::BaseDirectories;
 
 use pathpatterns::{MatchEntry, MatchType, PatternFlag};
@@ -306,7 +307,7 @@ async fn backup_directory<P: AsRef<Path>>(
 
     let (mut tx, rx) = mpsc::channel(10); // allow to buffer 10 chunks
 
-    let stream = rx
+    let stream = ReceiverStream::new(rx)
         .map_err(Error::from);
 
     // spawn chunker inside a separate task so that it can run parallel
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index 2228253d..16450244 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -6,6 +6,7 @@ use anyhow::{bail, format_err, Error};
 use futures::*;
 use hyper;
 use openssl::ssl::{SslMethod, SslAcceptor, SslFiletype};
+use tokio_stream::wrappers::ReceiverStream;
 
 use proxmox::try_block;
 use proxmox::api::RpcEnvironmentType;
@@ -122,7 +123,7 @@ async fn run() -> Result<(), Error> {
         |listener, ready| {
 
             let connections = accept_connections(listener, acceptor, debug);
-            let connections = hyper::server::accept::from_stream(connections);
+            let connections = hyper::server::accept::from_stream(ReceiverStream::new(connections));
 
             Ok(ready
                .and_then(|_| hyper::Server::builder(connections)
diff --git a/src/client/backup_writer.rs b/src/client/backup_writer.rs
index 39cd574d..bcbd6f28 100644
--- a/src/client/backup_writer.rs
+++ b/src/client/backup_writer.rs
@@ -10,6 +10,7 @@ use futures::future::AbortHandle;
 use serde_json::{json, Value};
 use tokio::io::AsyncReadExt;
 use tokio::sync::{mpsc, oneshot};
+use tokio_stream::wrappers::ReceiverStream;
 
 use proxmox::tools::digest_to_hex;
 
@@ -321,7 +322,7 @@ impl BackupWriter {
         // });
         // old code for reference?
         tokio::spawn(
-            verify_queue_rx
+            ReceiverStream::new(verify_queue_rx)
                 .map(Ok::<_, Error>)
                 .try_for_each(move |response: h2::client::ResponseFuture| {
                     response
@@ -349,7 +350,7 @@ impl BackupWriter {
 
         // FIXME: async-block-ify this code!
         tokio::spawn(
-            verify_queue_rx
+            ReceiverStream::new(verify_queue_rx)
                 .map(Ok::<_, Error>)
                 .and_then(move |(merged_chunk_info, response): (MergedChunkInfo, Option<h2::client::ResponseFuture>)| {
                     match (response, merged_chunk_info) {
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 08/12] tokio 1.0: update to new tokio-openssl interface
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (10 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 07/12] tokio 1.0: use ReceiverStream from tokio-stream Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 09/12] tokio 1.0: update to new Signal interface Fabian Grünbichler
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

connect/accept are now happening on pinned SslStreams

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---

Notes:
    there might be further potential to improve error handling now?

 src/bin/proxmox-backup-proxy.rs | 27 ++++++++++++++++++++++-----
 src/server/rest.rs              |  4 ++--
 src/tools/async_io.rs           |  2 +-
 src/tools/http.rs               | 11 +++++------
 4 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index 16450244..c8eb237c 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -167,7 +167,7 @@ fn accept_connections(
     mut listener: tokio::net::TcpListener,
     acceptor: Arc<openssl::ssl::SslAcceptor>,
     debug: bool,
-) -> tokio::sync::mpsc::Receiver<Result<tokio_openssl::SslStream<tokio::net::TcpStream>, Error>> {
+) -> tokio::sync::mpsc::Receiver<Result<std::pin::Pin<Box<tokio_openssl::SslStream<tokio::net::TcpStream>>>, Error>> {
 
     const MAX_PENDING_ACCEPTS: usize = 1024;
 
@@ -185,7 +185,24 @@ fn accept_connections(
                     sock.set_nodelay(true).unwrap();
                     let _ = set_tcp_keepalive(sock.as_raw_fd(), PROXMOX_BACKUP_TCP_KEEPALIVE_TIME);
                     let acceptor = Arc::clone(&acceptor);
-                    let mut sender = sender.clone();
+
+                    let ssl = match openssl::ssl::Ssl::new(acceptor.context()) {
+                        Ok(ssl) => ssl,
+                        Err(err) => {
+                            eprintln!("failed to create Ssl object from Acceptor context - {}", err);
+                            continue;
+                        },
+                    };
+                    let stream = match tokio_openssl::SslStream::new(ssl, sock) {
+                        Ok(stream) => stream,
+                        Err(err) => {
+                            eprintln!("failed to create SslStream using ssl and connection socket - {}", err);
+                            continue;
+                        },
+                    };
+
+                    let mut stream = Box::pin(stream);
+                    let sender = sender.clone();
 
                     if Arc::strong_count(&accept_counter) > MAX_PENDING_ACCEPTS {
                         eprintln!("connection rejected - to many open connections");
@@ -195,13 +212,13 @@ fn accept_connections(
                     let accept_counter = accept_counter.clone();
                     tokio::spawn(async move {
                         let accept_future = tokio::time::timeout(
-                            Duration::new(10, 0), tokio_openssl::accept(&acceptor, sock));
+                            Duration::new(10, 0), stream.as_mut().accept());
 
                         let result = accept_future.await;
 
                         match result {
-                            Ok(Ok(connection)) => {
-                                if let Err(_) = sender.send(Ok(connection)).await {
+                            Ok(Ok(())) => {
+                                if let Err(_) = sender.send(Ok(stream)).await {
                                     if debug {
                                         eprintln!("detect closed connection channel");
                                     }
diff --git a/src/server/rest.rs b/src/server/rest.rs
index 04bdc5f9..c30d1c92 100644
--- a/src/server/rest.rs
+++ b/src/server/rest.rs
@@ -65,7 +65,7 @@ impl RestServer {
     }
 }
 
-impl tower_service::Service<&tokio_openssl::SslStream<tokio::net::TcpStream>> for RestServer {
+impl tower_service::Service<&Pin<Box<tokio_openssl::SslStream<tokio::net::TcpStream>>>> for RestServer {
     type Response = ApiService;
     type Error = Error;
     type Future = Pin<Box<dyn Future<Output = Result<ApiService, Error>> + Send>>;
@@ -74,7 +74,7 @@ impl tower_service::Service<&tokio_openssl::SslStream<tokio::net::TcpStream>> fo
         Poll::Ready(Ok(()))
     }
 
-    fn call(&mut self, ctx: &tokio_openssl::SslStream<tokio::net::TcpStream>) -> Self::Future {
+    fn call(&mut self, ctx: &Pin<Box<tokio_openssl::SslStream<tokio::net::TcpStream>>>) -> Self::Future {
         match ctx.get_ref().peer_addr() {
             Err(err) => {
                 future::err(format_err!("unable to get peer address - {}", err)).boxed()
diff --git a/src/tools/async_io.rs b/src/tools/async_io.rs
index 3a5a6c9a..997c02fa 100644
--- a/src/tools/async_io.rs
+++ b/src/tools/async_io.rs
@@ -74,7 +74,7 @@ impl<L: AsyncWrite + Unpin, R: AsyncWrite + Unpin> AsyncWrite for EitherStream<L
 // we need this for crate::client::http_client:
 impl Connection for EitherStream<
     tokio::net::TcpStream,
-    tokio_openssl::SslStream<tokio::net::TcpStream>,
+    Pin<Box<tokio_openssl::SslStream<tokio::net::TcpStream>>>,
 > {
     fn connected(&self) -> hyper::client::connect::Connected {
         match self {
diff --git a/src/tools/http.rs b/src/tools/http.rs
index 130aa381..47d6e1f6 100644
--- a/src/tools/http.rs
+++ b/src/tools/http.rs
@@ -3,6 +3,7 @@ use lazy_static::lazy_static;
 use std::task::{Context, Poll};
 use std::os::unix::io::AsRawFd;
 use std::collections::HashMap;
+use std::pin::Pin;
 
 use hyper::{Uri, Body};
 use hyper::client::{Client, HttpConnector};
@@ -101,7 +102,7 @@ impl HttpsConnector {
 
 type MaybeTlsStream = EitherStream<
     tokio::net::TcpStream,
-    tokio_openssl::SslStream<tokio::net::TcpStream>,
+    Pin<Box<tokio_openssl::SslStream<tokio::net::TcpStream>>>,
 >;
 
 impl hyper::service::Service<Uri> for HttpsConnector {
@@ -123,10 +124,6 @@ impl hyper::service::Service<Uri> for HttpsConnector {
                 .scheme()
                 .ok_or_else(|| format_err!("missing URL scheme"))?
                 == "https";
-            let host = dst
-                .host()
-                .ok_or_else(|| format_err!("missing hostname in destination url?"))?
-                .to_string();
 
             let config = this.ssl_connector.configure();
             let dst_str = dst.to_string(); // for error messages
@@ -139,7 +136,9 @@ impl hyper::service::Service<Uri> for HttpsConnector {
             let _ = set_tcp_keepalive(conn.as_raw_fd(), PROXMOX_BACKUP_TCP_KEEPALIVE_TIME);
 
             if is_https {
-                let conn = tokio_openssl::connect(config?, &host, conn).await?;
+                let conn: tokio_openssl::SslStream<tokio::net::TcpStream> = tokio_openssl::SslStream::new(config?.into_ssl(&dst_str)?, conn)?;
+                let mut conn = Box::pin(conn);
+                conn.as_mut().connect().await?;
                 Ok(MaybeTlsStream::Right(conn))
             } else {
                 Ok(MaybeTlsStream::Left(conn))
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 09/12] tokio 1.0: update to new Signal interface
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (11 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 08/12] tokio 1.0: update to new tokio-openssl interface Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 10/12] hyper: use new hyper::upgrade Fabian Grünbichler
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

Signal does not yet re-implement Stream (and is not yet wrapped in
tokio-stream either).

see https://github.com/tokio-rs/tokio/pull/3383

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/bin/proxmox_backup_client/mount.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/bin/proxmox_backup_client/mount.rs b/src/bin/proxmox_backup_client/mount.rs
index 6a22f78b..204ed7fc 100644
--- a/src/bin/proxmox_backup_client/mount.rs
+++ b/src/bin/proxmox_backup_client/mount.rs
@@ -246,7 +246,8 @@ async fn mount_do(param: Value, pipe: Option<Fd>) -> Result<Value, Error> {
     // handle SIGINT and SIGTERM
     let mut interrupt_int = signal(SignalKind::interrupt())?;
     let mut interrupt_term = signal(SignalKind::terminate())?;
-    let mut interrupt = futures::future::select(interrupt_int.next(), interrupt_term.next());
+
+    let mut interrupt = futures::future::select(interrupt_int.recv().boxed(), interrupt_term.recv().boxed());
 
     if server_archive_name.ends_with(".didx") {
         let index = client.download_dynamic_index(&manifest, &server_archive_name).await?;
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 10/12] hyper: use new hyper::upgrade
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (12 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 09/12] tokio 1.0: update to new Signal interface Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 11/12] examples: unify h2 examples Fabian Grünbichler
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

the old Body::on_upgrade method is no more

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/api2/backup.rs        | 5 ++---
 src/api2/node.rs          | 5 +++--
 src/api2/reader.rs        | 5 ++---
 src/client/http_client.rs | 5 +----
 4 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/api2/backup.rs b/src/api2/backup.rs
index f4eed074..bf9c1465 100644
--- a/src/api2/backup.rs
+++ b/src/api2/backup.rs
@@ -2,7 +2,7 @@ use anyhow::{bail, format_err, Error};
 use futures::*;
 use hyper::header::{HeaderValue, UPGRADE};
 use hyper::http::request::Parts;
-use hyper::{Body, Response, StatusCode};
+use hyper::{Body, Response, Request, StatusCode};
 use serde_json::{json, Value};
 
 use proxmox::{sortable, identity, list_subdirs_api_method};
@@ -171,8 +171,7 @@ async move {
 
         let env2 = env.clone();
 
-        let mut req_fut = req_body
-            .on_upgrade()
+        let mut req_fut = hyper::upgrade::on(Request::from_parts(parts, req_body))
             .map_err(Error::from)
             .and_then(move |conn| {
                 env2.debug("protocol upgrade done");
diff --git a/src/api2/node.rs b/src/api2/node.rs
index 51dfdd19..78e0fa44 100644
--- a/src/api2/node.rs
+++ b/src/api2/node.rs
@@ -6,6 +6,7 @@ use futures::future::{FutureExt, TryFutureExt};
 use hyper::body::Body;
 use hyper::http::request::Parts;
 use hyper::upgrade::Upgraded;
+use hyper::Request;
 use serde_json::{json, Value};
 use tokio::io::{AsyncBufReadExt, BufReader};
 
@@ -292,10 +293,10 @@ fn upgrade_to_websocket(
                 Some(&ticket::term_aad(&userid, "/system", port)),
             )?;
 
-        let (ws, response) = WebSocket::new(parts.headers)?;
+        let (ws, response) = WebSocket::new(parts.headers.clone())?;
 
         crate::server::spawn_internal_task(async move {
-            let conn: Upgraded = match req_body.on_upgrade().map_err(Error::from).await {
+            let conn: Upgraded = match hyper::upgrade::on(Request::from_parts(parts, req_body)).map_err(Error::from).await {
                 Ok(upgraded) => upgraded,
                 _ => bail!("error"),
             };
diff --git a/src/api2/reader.rs b/src/api2/reader.rs
index 010d73e3..72b6e33a 100644
--- a/src/api2/reader.rs
+++ b/src/api2/reader.rs
@@ -2,7 +2,7 @@ use anyhow::{bail, format_err, Error};
 use futures::*;
 use hyper::header::{self, HeaderValue, UPGRADE};
 use hyper::http::request::Parts;
-use hyper::{Body, Response, StatusCode};
+use hyper::{Body, Response, Request, StatusCode};
 use serde_json::Value;
 
 use proxmox::{sortable, identity};
@@ -130,8 +130,7 @@ fn upgrade_to_backup_reader_protocol(
 
             let abort_future = worker.abort_future();
 
-            let req_fut = req_body
-                .on_upgrade()
+            let req_fut = hyper::upgrade::on(Request::from_parts(parts, req_body))
                 .map_err(Error::from)
                 .and_then({
                     let env = env.clone();
diff --git a/src/client/http_client.rs b/src/client/http_client.rs
index 33860abf..3a934062 100644
--- a/src/client/http_client.rs
+++ b/src/client/http_client.rs
@@ -646,10 +646,7 @@ impl HttpClient {
             bail!("unknown error");
         }
 
-        let upgraded = resp
-            .into_body()
-            .on_upgrade()
-            .await?;
+        let upgraded = hyper::upgrade::on(resp).await?;
 
         let max_window_size = (1 << 31) - 2;
 
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 11/12] examples: unify h2 examples
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (13 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 10/12] hyper: use new hyper::upgrade Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 12/12] cleanup: remove unnecessary 'mut' and '.clone()' Fabian Grünbichler
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

update them to the new tokio-openssl API and remove socket buffer size
setting - it was removed from the TcpStream API, and is now only
available via TcpSocket (which can in turn be converted to a
TcpListener), but this is not needed for this example.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 examples/h2client.rs   | 37 +++++++++++------------
 examples/h2s-client.rs | 67 +++++++++++++++++++-----------------------
 examples/h2s-server.rs | 42 +++++++++++++-------------
 examples/h2server.rs   | 56 +++++++++++++++++++----------------
 4 files changed, 100 insertions(+), 102 deletions(-)

diff --git a/examples/h2client.rs b/examples/h2client.rs
index 87a6e326..8551af87 100644
--- a/examples/h2client.rs
+++ b/examples/h2client.rs
@@ -2,7 +2,7 @@ use std::future::Future;
 use std::pin::Pin;
 use std::task::{Context, Poll};
 
-use anyhow::{Error};
+use anyhow::Error;
 use futures::future::TryFutureExt;
 use futures::stream::Stream;
 use tokio::net::TcpStream;
@@ -38,11 +38,11 @@ impl Future for Process {
                         this.body.flow_control().release_capacity(chunk.len())?;
                         this.bytes += chunk.len();
                         // println!("GOT FRAME {}", chunk.len());
-                    },
+                    }
                     Some(Err(err)) => return Poll::Ready(Err(Error::from(err))),
                     None => {
                         this.trailers = true;
-                    },
+                    }
                 }
             }
         }
@@ -52,7 +52,6 @@ impl Future for Process {
 fn send_request(
     mut client: h2::client::SendRequest<bytes::Bytes>,
 ) -> impl Future<Output = Result<usize, Error>> {
-
     println!("sending request");
 
     let request = http::Request::builder()
@@ -62,11 +61,11 @@ fn send_request(
 
     let (response, _stream) = client.send_request(request, true).unwrap();
 
-    response
-        .map_err(Error::from)
-        .and_then(|response| {
-            Process { body: response.into_body(), trailers: false, bytes: 0 }
-        })
+    response.map_err(Error::from).and_then(|response| Process {
+        body: response.into_body(),
+        trailers: false,
+        bytes: 0,
+    })
 }
 
 fn main() -> Result<(), Error> {
@@ -74,16 +73,15 @@ fn main() -> Result<(), Error> {
 }
 
 async fn run() -> Result<(), Error> {
-
     let start = std::time::SystemTime::now();
 
-    let conn = TcpStream::connect(std::net::SocketAddr::from(([127,0,0,1], 8008)))
-        .await?;
+    let conn = TcpStream::connect(std::net::SocketAddr::from(([127, 0, 0, 1], 8008))).await?;
+    conn.set_nodelay(true).unwrap();
 
     let (client, h2) = h2::client::Builder::new()
-        .initial_connection_window_size(1024*1024*1024)
-        .initial_window_size(1024*1024*1024)
-        .max_frame_size(4*1024*1024)
+        .initial_connection_window_size(1024 * 1024 * 1024)
+        .initial_window_size(1024 * 1024 * 1024)
+        .max_frame_size(4 * 1024 * 1024)
         .handshake(conn)
         .await?;
 
@@ -99,10 +97,13 @@ async fn run() -> Result<(), Error> {
     }
 
     let elapsed = start.elapsed().unwrap();
-    let elapsed = (elapsed.as_secs() as f64) +
-        (elapsed.subsec_millis() as f64)/1000.0;
+    let elapsed = (elapsed.as_secs() as f64) + (elapsed.subsec_millis() as f64) / 1000.0;
 
-    println!("Downloaded {} bytes, {} MB/s", bytes, (bytes as f64)/(elapsed*1024.0*1024.0));
+    println!(
+        "Downloaded {} bytes, {} MB/s",
+        bytes,
+        (bytes as f64) / (elapsed * 1024.0 * 1024.0)
+    );
 
     Ok(())
 }
diff --git a/examples/h2s-client.rs b/examples/h2s-client.rs
index 0d6beaef..a3b0d22c 100644
--- a/examples/h2s-client.rs
+++ b/examples/h2s-client.rs
@@ -5,6 +5,7 @@ use std::task::{Context, Poll};
 use anyhow::{format_err, Error};
 use futures::future::TryFutureExt;
 use futures::stream::Stream;
+use tokio::net::TcpStream;
 
 // Simple H2 client to test H2 download speed using h2s-server.rs
 
@@ -37,11 +38,11 @@ impl Future for Process {
                         this.body.flow_control().release_capacity(chunk.len())?;
                         this.bytes += chunk.len();
                         // println!("GOT FRAME {}", chunk.len());
-                    },
+                    }
                     Some(Err(err)) => return Poll::Ready(Err(Error::from(err))),
                     None => {
                         this.trailers = true;
-                    },
+                    }
                 }
             }
         }
@@ -60,11 +61,11 @@ fn send_request(
 
     let (response, _stream) = client.send_request(request, true).unwrap();
 
-    response
-        .map_err(Error::from)
-        .and_then(|response| {
-            Process { body: response.into_body(), trailers: false, bytes: 0 }
-        })
+    response.map_err(Error::from).and_then(|response| Process {
+        body: response.into_body(),
+        trailers: false,
+        bytes: 0,
+    })
 }
 
 fn main() -> Result<(), Error> {
@@ -74,57 +75,51 @@ fn main() -> Result<(), Error> {
 async fn run() -> Result<(), Error> {
     let start = std::time::SystemTime::now();
 
-    let conn =
-        tokio::net::TcpStream::connect(std::net::SocketAddr::from(([127,0,0,1], 8008))).await?;
-
+    let conn = TcpStream::connect(std::net::SocketAddr::from(([127, 0, 0, 1], 8008))).await?;
     conn.set_nodelay(true).unwrap();
-    conn.set_recv_buffer_size(1024*1024).unwrap();
 
     use openssl::ssl::{SslConnector, SslMethod};
 
     let mut ssl_connector_builder = SslConnector::builder(SslMethod::tls()).unwrap();
     ssl_connector_builder.set_verify(openssl::ssl::SslVerifyMode::NONE);
-    let conn =
-        tokio_openssl::connect(
-            ssl_connector_builder.build().configure()?,
-            "localhost",
-            conn,
-        )
+    let ssl = ssl_connector_builder
+        .build()
+        .configure()?
+        .into_ssl("localhost")?;
+
+    let conn = tokio_openssl::SslStream::new(ssl, conn)?;
+    let mut conn = Box::pin(conn);
+    conn.as_mut()
+        .connect()
         .await
         .map_err(|err| format_err!("connect failed - {}", err))?;
 
     let (client, h2) = h2::client::Builder::new()
-        .initial_connection_window_size(1024*1024*1024)
-        .initial_window_size(1024*1024*1024)
-        .max_frame_size(4*1024*1024)
+        .initial_connection_window_size(1024 * 1024 * 1024)
+        .initial_window_size(1024 * 1024 * 1024)
+        .max_frame_size(4 * 1024 * 1024)
         .handshake(conn)
         .await?;
 
-    // Spawn a task to run the conn...
     tokio::spawn(async move {
-        if let Err(e) = h2.await {
-            println!("GOT ERR={:?}", e);
+        if let Err(err) = h2.await {
+            println!("GOT ERR={:?}", err);
         }
     });
 
     let mut bytes = 0;
-    for _ in 0..100 {
-        match send_request(client.clone()).await {
-            Ok(b) => {
-                bytes += b;
-            }
-            Err(e) => {
-                println!("ERROR {}", e);
-                return Ok(());
-            }
-        }
+    for _ in 0..2000 {
+        bytes += send_request(client.clone()).await?;
     }
 
     let elapsed = start.elapsed().unwrap();
-    let elapsed = (elapsed.as_secs() as f64) +
-        (elapsed.subsec_millis() as f64)/1000.0;
+    let elapsed = (elapsed.as_secs() as f64) + (elapsed.subsec_millis() as f64) / 1000.0;
 
-    println!("Downloaded {} bytes, {} MB/s", bytes, (bytes as f64)/(elapsed*1024.0*1024.0));
+    println!(
+        "Downloaded {} bytes, {} MB/s",
+        bytes,
+        (bytes as f64) / (elapsed * 1024.0 * 1024.0)
+    );
 
     Ok(())
 }
diff --git a/examples/h2s-server.rs b/examples/h2s-server.rs
index 8481b8ad..4357fe45 100644
--- a/examples/h2s-server.rs
+++ b/examples/h2s-server.rs
@@ -2,14 +2,12 @@ use std::sync::Arc;
 
 use anyhow::{format_err, Error};
 use futures::*;
-use hyper::{Request, Response, Body};
-use openssl::ssl::{SslMethod, SslAcceptor, SslFiletype};
+use hyper::{Body, Request, Response};
+use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
 use tokio::net::{TcpListener, TcpStream};
 
 use proxmox_backup::configdir;
 
-// Simple H2 server to test H2 speed with h2s-client.rs
-
 fn main() -> Result<(), Error> {
     proxmox_backup::tools::runtime::main(run())
 }
@@ -19,38 +17,38 @@ async fn run() -> Result<(), Error> {
     let cert_path = configdir!("/proxy.pem");
 
     let mut acceptor = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap();
-    acceptor.set_private_key_file(key_path, SslFiletype::PEM)
+    acceptor
+        .set_private_key_file(key_path, SslFiletype::PEM)
         .map_err(|err| format_err!("unable to read proxy key {} - {}", key_path, err))?;
-    acceptor.set_certificate_chain_file(cert_path)
+    acceptor
+        .set_certificate_chain_file(cert_path)
         .map_err(|err| format_err!("unable to read proxy cert {} - {}", cert_path, err))?;
     acceptor.check_private_key().unwrap();
 
     let acceptor = Arc::new(acceptor.build());
 
-    let mut listener = TcpListener::bind(std::net::SocketAddr::from(([127,0,0,1], 8008))).await?;
+    let listener = TcpListener::bind(std::net::SocketAddr::from(([127, 0, 0, 1], 8008))).await?;
 
     println!("listening on {:?}", listener.local_addr());
 
     loop {
         let (socket, _addr) = listener.accept().await?;
-        tokio::spawn(handle_connection(socket, Arc::clone(&acceptor))
-            .map(|res| {
-                if let Err(err) = res {
-                    eprintln!("Error: {}", err);
-                }
-            }));
+        tokio::spawn(handle_connection(socket, Arc::clone(&acceptor)).map(|res| {
+            if let Err(err) = res {
+                eprintln!("Error: {}", err);
+            }
+        }));
     }
 }
 
-async fn handle_connection(
-    socket: TcpStream,
-    acceptor: Arc<SslAcceptor>,
-) -> Result<(), Error> {
+async fn handle_connection(socket: TcpStream, acceptor: Arc<SslAcceptor>) -> Result<(), Error> {
     socket.set_nodelay(true).unwrap();
-    socket.set_send_buffer_size(1024*1024).unwrap();
-    socket.set_recv_buffer_size(1024*1024).unwrap();
 
-    let socket = tokio_openssl::accept(acceptor.as_ref(), socket).await?;
+    let ssl = openssl::ssl::Ssl::new(acceptor.context())?;
+    let stream = tokio_openssl::SslStream::new(ssl, socket)?;
+    let mut stream = Box::pin(stream);
+
+    stream.as_mut().accept().await?;
 
     let mut http = hyper::server::conn::Http::new();
     http.http2_only(true);
@@ -61,7 +59,7 @@ async fn handle_connection(
 
     let service = hyper::service::service_fn(|_req: Request<Body>| {
         println!("Got request");
-        let buffer = vec![65u8; 1024*1024]; // nonsense [A,A,A,A...]
+        let buffer = vec![65u8; 4 * 1024 * 1024]; // nonsense [A,A,A,A...]
         let body = Body::from(buffer);
 
         let response = Response::builder()
@@ -72,7 +70,7 @@ async fn handle_connection(
         future::ok::<_, Error>(response)
     });
 
-    http.serve_connection(socket, service)
+    http.serve_connection(stream, service)
         .map_err(Error::from)
         .await?;
 
diff --git a/examples/h2server.rs b/examples/h2server.rs
index 1669347f..1b06557c 100644
--- a/examples/h2server.rs
+++ b/examples/h2server.rs
@@ -1,51 +1,55 @@
-use anyhow::{Error};
+use anyhow::Error;
 use futures::*;
+use hyper::{Body, Request, Response};
 
-// Simple H2 server to test H2 speed with h2client.rs
-
-use tokio::net::TcpListener;
-use tokio::io::{AsyncRead, AsyncWrite};
-
-use proxmox_backup::client::pipe_to_stream::PipeToSendStream;
+use tokio::net::{TcpListener, TcpStream};
 
 fn main() -> Result<(), Error> {
     proxmox_backup::tools::runtime::main(run())
 }
 
 async fn run() -> Result<(), Error> {
-    let mut listener = TcpListener::bind(std::net::SocketAddr::from(([127,0,0,1], 8008))).await?;
+    let listener = TcpListener::bind(std::net::SocketAddr::from(([127, 0, 0, 1], 8008))).await?;
 
     println!("listening on {:?}", listener.local_addr());
 
     loop {
         let (socket, _addr) = listener.accept().await?;
-        tokio::spawn(handle_connection(socket)
-            .map(|res| {
-                if let Err(err) = res {
-                    eprintln!("Error: {}", err);
-                }
-            }));
+        tokio::spawn(handle_connection(socket).map(|res| {
+            if let Err(err) = res {
+                eprintln!("Error: {}", err);
+            }
+        }));
     }
 }
 
-async fn handle_connection<T: AsyncRead + AsyncWrite + Unpin>(socket: T) -> Result<(), Error> {
-    let mut conn = h2::server::handshake(socket).await?;
+async fn handle_connection(socket: TcpStream) -> Result<(), Error> {
+    socket.set_nodelay(true).unwrap();
 
-    println!("H2 connection bound");
+    let mut http = hyper::server::conn::Http::new();
+    http.http2_only(true);
+    // increase window size: todo - find optiomal size
+    let max_window_size = (1 << 31) - 2;
+    http.http2_initial_stream_window_size(max_window_size);
+    http.http2_initial_connection_window_size(max_window_size);
 
-    while let Some((request, mut respond)) = conn.try_next().await? {
-        println!("GOT request: {:?}", request);
+    let service = hyper::service::service_fn(|_req: Request<Body>| {
+        println!("Got request");
+        let buffer = vec![65u8; 4 * 1024 * 1024]; // nonsense [A,A,A,A...]
+        let body = Body::from(buffer);
 
-        let response = http::Response::builder()
+        let response = Response::builder()
             .status(http::StatusCode::OK)
-            .body(())
+            .header(http::header::CONTENT_TYPE, "application/octet-stream")
+            .body(body)
             .unwrap();
+        future::ok::<_, Error>(response)
+    });
 
-        let send = respond.send_response(response, false).unwrap();
-        let data = vec![65u8; 1024*1024];
-        PipeToSendStream::new(bytes::Bytes::from(data), send).await?;
-        println!("DATA SENT");
-    }
+    http.serve_connection(socket, service)
+        .map_err(Error::from)
+        .await?;
 
+    println!("H2 connection CLOSE !");
     Ok(())
 }
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 12/12] cleanup: remove unnecessary 'mut' and '.clone()'
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (14 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 11/12] examples: unify h2 examples Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-fuse] update to tokio 1.0 Fabian Grünbichler
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/bin/proxmox-backup-client.rs       | 2 +-
 src/bin/proxmox-backup-proxy.rs        | 2 +-
 src/bin/proxmox_backup_client/mount.rs | 2 +-
 src/client/backup_writer.rs            | 5 +----
 src/server/command_socket.rs           | 2 +-
 src/tools/async_channel_writer.rs      | 2 +-
 src/tools/broadcast_future.rs          | 2 +-
 tests/worker-task-abort.rs             | 2 +-
 8 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs
index d91f04cc..2cd00c2e 100644
--- a/src/bin/proxmox-backup-client.rs
+++ b/src/bin/proxmox-backup-client.rs
@@ -305,7 +305,7 @@ async fn backup_directory<P: AsRef<Path>>(
     )?;
     let mut chunk_stream = ChunkStream::new(pxar_stream, chunk_size);
 
-    let (mut tx, rx) = mpsc::channel(10); // allow to buffer 10 chunks
+    let (tx, rx) = mpsc::channel(10); // allow to buffer 10 chunks
 
     let stream = ReceiverStream::new(rx)
         .map_err(Error::from);
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index c8eb237c..39e8d537 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -164,7 +164,7 @@ async fn run() -> Result<(), Error> {
 }
 
 fn accept_connections(
-    mut listener: tokio::net::TcpListener,
+    listener: tokio::net::TcpListener,
     acceptor: Arc<openssl::ssl::SslAcceptor>,
     debug: bool,
 ) -> tokio::sync::mpsc::Receiver<Result<std::pin::Pin<Box<tokio_openssl::SslStream<tokio::net::TcpStream>>>, Error>> {
diff --git a/src/bin/proxmox_backup_client/mount.rs b/src/bin/proxmox_backup_client/mount.rs
index 204ed7fc..f8410709 100644
--- a/src/bin/proxmox_backup_client/mount.rs
+++ b/src/bin/proxmox_backup_client/mount.rs
@@ -294,7 +294,7 @@ async fn mount_do(param: Value, pipe: Option<Fd>) -> Result<Value, Error> {
 
         // poll until loop file is mapped (or errors)
         select! {
-            res = session_fut => {
+            _res = session_fut => {
                 bail!("FUSE session unexpectedly ended before loop file mapping");
             },
             res = st_recv.try_next() => {
diff --git a/src/client/backup_writer.rs b/src/client/backup_writer.rs
index bcbd6f28..e7a6d6bd 100644
--- a/src/client/backup_writer.rs
+++ b/src/client/backup_writer.rs
@@ -583,6 +583,7 @@ impl BackupWriter {
             })
             .merge_known_chunks()
             .try_for_each(move |merged_chunk_info| {
+                let upload_queue = upload_queue.clone();
 
                 if let MergedChunkInfo::New(chunk_info) = merged_chunk_info {
                     let offset = chunk_info.offset;
@@ -610,7 +611,6 @@ impl BackupWriter {
 
                     let new_info = MergedChunkInfo::Known(vec![(offset, digest)]);
 
-                    let mut upload_queue = upload_queue.clone();
                     future::Either::Left(h2
                         .send_request(request, upload_data)
                         .and_then(move |response| async move {
@@ -621,7 +621,6 @@ impl BackupWriter {
                         })
                     )
                 } else {
-                    let mut upload_queue = upload_queue.clone();
                     future::Either::Right(async move {
                         upload_queue
                             .send((merged_chunk_info, None))
@@ -673,8 +672,6 @@ impl BackupWriter {
                 break;
             }
 
-            let mut upload_queue = upload_queue.clone();
-
             if verbose { eprintln!("send test data ({} bytes)", data.len()); }
             let request = H2Client::request_builder("localhost", "POST", "speedtest", None, None).unwrap();
             let request_future = self.h2.send_request(request, Some(bytes::Bytes::from(data.clone()))).await?;
diff --git a/src/server/command_socket.rs b/src/server/command_socket.rs
index 08e59173..84d4e9fe 100644
--- a/src/server/command_socket.rs
+++ b/src/server/command_socket.rs
@@ -21,7 +21,7 @@ where
     let backup_user = crate::backup::backup_user()?;
     let backup_gid = backup_user.gid.as_raw();
 
-    let mut socket = UnixListener::bind(&path)?;
+    let socket = UnixListener::bind(&path)?;
 
     let func = Arc::new(func);
 
diff --git a/src/tools/async_channel_writer.rs b/src/tools/async_channel_writer.rs
index 4bb56ac5..f48bd555 100644
--- a/src/tools/async_channel_writer.rs
+++ b/src/tools/async_channel_writer.rs
@@ -58,7 +58,7 @@ impl AsyncChannelWriter {
                         }
                     }
 
-                    let mut sender = match self.sender.take() {
+                    let sender = match self.sender.take() {
                         Some(sender) => sender,
                         None => return Poll::Ready(Err(io_err_other("no sender"))),
                     };
diff --git a/src/tools/broadcast_future.rs b/src/tools/broadcast_future.rs
index 1c82bdc3..3c96d2dc 100644
--- a/src/tools/broadcast_future.rs
+++ b/src/tools/broadcast_future.rs
@@ -159,7 +159,7 @@ fn test_broadcast_future() {
         .map_err(|err| { panic!("got error {}", err); })
         .map(|_| ());
 
-    let mut rt = tokio::runtime::Runtime::new().unwrap();
+    let rt = tokio::runtime::Runtime::new().unwrap();
     rt.block_on(async move {
         let r1 = tokio::spawn(receiver1);
         let r2 = tokio::spawn(receiver2);
diff --git a/tests/worker-task-abort.rs b/tests/worker-task-abort.rs
index 5b73c8b9..7ec3958c 100644
--- a/tests/worker-task-abort.rs
+++ b/tests/worker-task-abort.rs
@@ -39,7 +39,7 @@ fn worker_task_abort() -> Result<(), Error> {
     let errmsg: Arc<Mutex<Option<String>>> = Arc::new(Mutex::new(None));
     let errmsg1 = errmsg.clone();
 
-    let mut rt = tokio::runtime::Runtime::new().unwrap();
+    let rt = tokio::runtime::Runtime::new().unwrap();
     rt.block_on(async move {
 
         let mut commando_sock = server::CommandoSocket::new(server::our_ctrl_sock());
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-fuse] update to tokio 1.0
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (15 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 12/12] cleanup: remove unnecessary 'mut' and '.clone()' Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [PATCH pxar 1/3] " Fabian Grünbichler
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

PollEvented is no more (it's an internal API now, since tokio no longer
wants to expose mio parts in its public API). Switch to AsyncFd, which
provides similar mechanisms for non-blocking raw FDs and allows us to
drop our own direct mio dependency as well.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 Cargo.toml     |  7 +++++--
 debian/control | 22 ++++++++++------------
 src/fuse_fd.rs | 30 ------------------------------
 src/session.rs | 14 ++++++--------
 4 files changed, 21 insertions(+), 52 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index ef3fa2b..0303522 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,5 +12,8 @@ exclude = [ "build", "debian" ]
 anyhow = "1.0"
 futures = "0.3"
 libc = "0.2"
-mio = "0.6.21"
-tokio = { version = "0.2", features = ["io-driver", "macros", "signal", "stream"] }
+tokio = { version = "1.0", features = ["macros", "net", "signal"] }
+tokio-stream = "0.1"
+
+[dev-dependencies]
+tokio = { version = "1.0", features = ["rt-multi-thread"] }
diff --git a/debian/control b/debian/control
index 7e8c45d..4d20e04 100644
--- a/debian/control
+++ b/debian/control
@@ -9,12 +9,11 @@ Build-Depends: debhelper (>= 11),
  librust-anyhow-1+default-dev <!nocheck>,
  librust-futures-0.3+default-dev <!nocheck>,
  librust-libc-0.2+default-dev <!nocheck>,
- librust-mio-0.6+default-dev (>= 0.6.21-~~) <!nocheck>,
- librust-tokio-0.2+default-dev <!nocheck>,
- librust-tokio-0.2+io-driver-dev <!nocheck>,
- librust-tokio-0.2+macros-dev <!nocheck>,
- librust-tokio-0.2+signal-dev <!nocheck>,
- librust-tokio-0.2+stream-dev <!nocheck>,
+ librust-tokio-1+default-dev <!nocheck>,
+ librust-tokio-1+macros-dev <!nocheck>,
+ librust-tokio-1+net-dev <!nocheck>,
+ librust-tokio-1+signal-dev <!nocheck>,
+ librust-tokio-stream-0.1+default-dev <!nocheck>,
  libfuse3-dev <!nocheck>
 Maintainer: Proxmox Support Team <support@proxmox.com>
 Standards-Version: 4.4.1
@@ -29,12 +28,11 @@ Depends:
  librust-anyhow-1+default-dev,
  librust-futures-0.3+default-dev,
  librust-libc-0.2+default-dev,
- librust-mio-0.6+default-dev (>= 0.6.21-~~),
- librust-tokio-0.2+default-dev,
- librust-tokio-0.2+io-driver-dev,
- librust-tokio-0.2+macros-dev,
- librust-tokio-0.2+signal-dev,
- librust-tokio-0.2+stream-dev,
+ librust-tokio-1+default-dev,
+ librust-tokio-1+macros-dev,
+ librust-tokio-1+net-dev,
+ librust-tokio-1+signal-dev,
+ librust-tokio-stream-0.1+default-dev,
  libfuse3-dev
 Provides:
  librust-proxmox-fuse+default-dev (= ${binary:Version}),
diff --git a/src/fuse_fd.rs b/src/fuse_fd.rs
index 68d9e79..0217689 100644
--- a/src/fuse_fd.rs
+++ b/src/fuse_fd.rs
@@ -3,10 +3,6 @@
 use std::io;
 use std::os::unix::io::{AsRawFd, RawFd};
 
-use mio::event::Evented;
-use mio::unix::EventedFd;
-use mio::{Poll, PollOpt, Ready, Token};
-
 pub struct FuseFd {
     fd: RawFd,
 }
@@ -38,29 +34,3 @@ impl AsRawFd for FuseFd {
         self.fd
     }
 }
-
-impl Evented for FuseFd {
-    fn register(
-        &self,
-        poll: &Poll,
-        token: Token,
-        interest: Ready,
-        opts: PollOpt,
-    ) -> io::Result<()> {
-        EventedFd(&self.fd).register(poll, token, interest, opts)
-    }
-
-    fn reregister(
-        &self,
-        poll: &Poll,
-        token: Token,
-        interest: Ready,
-        opts: PollOpt,
-    ) -> io::Result<()> {
-        EventedFd(&self.fd).reregister(poll, token, interest, opts)
-    }
-
-    fn deregister(&self, poll: &Poll) -> io::Result<()> {
-        EventedFd(&self.fd).deregister(poll)
-    }
-}
diff --git a/src/session.rs b/src/session.rs
index 125492a..78f558d 100644
--- a/src/session.rs
+++ b/src/session.rs
@@ -12,7 +12,7 @@ use std::{io, mem};
 use anyhow::{bail, format_err, Error};
 use futures::ready;
 use futures::stream::{FusedStream, Stream};
-use tokio::io::PollEvented;
+use tokio::io::unix::AsyncFd;
 
 use crate::fuse_fd::FuseFd;
 use crate::requests::{self, Request, RequestGuard};
@@ -610,7 +610,7 @@ impl FuseSession {
             bail!("failed to get fuse session file descriptor");
         }
 
-        let fuse_fd = PollEvented::new(FuseFd::from_raw(fd)?)?;
+        let fuse_fd = AsyncFd::new(FuseFd::from_raw(fd)?)?;
 
         // disable mount guard
         self.mounted = false;
@@ -650,7 +650,7 @@ unsafe impl Sync for SessionPtr {}
 pub struct Fuse {
     session: SessionPtr,
     fuse_data: Box<FuseData>,
-    fuse_fd: PollEvented<FuseFd>,
+    fuse_fd: AsyncFd<FuseFd>,
 }
 
 // We lose these via the raw session pointer:
@@ -691,7 +691,7 @@ impl Stream for Fuse {
                 return Poll::Ready(None);
             }
 
-            ready!(this.fuse_fd.poll_read_ready(cx, mio::Ready::readable()))?;
+            let mut ready_guard = ready!(this.fuse_fd.poll_read_ready(cx))?;
 
             let buf: &mut sys::FuseBuf = match Arc::get_mut(&mut this.fuse_data.fbuf) {
                 Some(buf) => buf,
@@ -705,10 +705,8 @@ impl Stream for Fuse {
             let rc = unsafe { sys::fuse_session_receive_buf(this.session.as_ptr(), Some(buf)) };
 
             if rc == -libc::EAGAIN {
-                match this.fuse_fd.clear_read_ready(cx, mio::Ready::readable()) {
-                    Ok(()) => continue,
-                    Err(err) => return Poll::Ready(Some(Err(err))),
-                }
+                ready_guard.clear_ready();
+                continue;
             } else if rc < 0 {
                 return Poll::Ready(Some(Err(io::Error::from_raw_os_error(-rc))));
             } else if rc == 0 {
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH pxar 1/3] update to tokio 1.0
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (16 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-fuse] update to tokio 1.0 Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [RFC pxar 2/3] clippy: use matches! instead of match Fabian Grünbichler
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

unfortunately, futures::io::AsyncRead and tokio::io::AsyncRead no longer
share a do_poll_read signature, so we need to adapt one to the other
(and also no longer generate some wrapper implementations via macro).

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 Cargo.toml          |   5 +--
 src/accessor/aio.rs |   7 +--
 src/decoder/aio.rs  | 105 ++++++++++++++++++++++++--------------------
 3 files changed, 64 insertions(+), 53 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 24b5489..875de7a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -47,7 +47,7 @@ siphasher = "0.3"
 
 anyhow = { version = "1.0", optional = true }
 futures = { version = "0.3.1", optional = true }
-tokio = { version = "0.2.10", optional = true, default-features = false }
+tokio = { version = "1.0", optional = true, default-features = false }
 
 [target.'cfg(target_os = "linux")'.dependencies]
 libc = "0.2"
@@ -65,8 +65,7 @@ async-example = [
     "futures-io",
     "tokio-io",
     "tokio-fs",
-    "tokio/rt-threaded",
-    "tokio/io-driver",
+    "tokio/rt-multi-thread",
     "tokio/macros",
 ]
 
diff --git a/src/accessor/aio.rs b/src/accessor/aio.rs
index a1aaa08..dd017ae 100644
--- a/src/accessor/aio.rs
+++ b/src/accessor/aio.rs
@@ -410,9 +410,10 @@ impl<T: Clone + ReadAt> tokio::io::AsyncRead for FileContents<T> {
     fn poll_read(
         self: Pin<&mut Self>,
         cx: &mut Context,
-        buf: &mut [u8],
-    ) -> Poll<io::Result<usize>> {
-        Self::do_poll_read(self, cx, buf)
+        buf: &mut tokio::io::ReadBuf,
+    ) -> Poll<io::Result<()>> {
+        Self::do_poll_read(self, cx, &mut buf.initialize_unfilled())
+            .map_ok(|bytes| { buf.set_filled(bytes); () })
     }
 }
 
diff --git a/src/decoder/aio.rs b/src/decoder/aio.rs
index e7152b3..1a5f5ea 100644
--- a/src/decoder/aio.rs
+++ b/src/decoder/aio.rs
@@ -136,61 +136,72 @@ mod stream {
 #[cfg(feature = "futures-io")]
 pub use stream::DecoderStream;
 
-macro_rules! async_io_impl {
-    (
-        #[cfg( $($attr:tt)+ )]
-        mod $mod:ident {
-            $(#[$docs:meta])*
-            $name:ident : $trait:path ;
-        }
-    ) => {
-        #[cfg( $($attr)+ )]
-        mod $mod {
-            use std::io;
-            use std::pin::Pin;
-            use std::task::{Context, Poll};
-
-            $(#[$docs])*
-            pub struct $name<T> {
-                inner: T,
-            }
+#[cfg(feature = "futures-io")]
+mod fut {
+    use std::io;
+    use std::pin::Pin;
+    use std::task::{Context, Poll};
 
-            impl<T: $trait> $name<T> {
-                pub fn new(inner: T) -> Self {
-                    Self { inner }
-                }
-            }
+    /// Read adapter for `futures::io::AsyncRead`
+    pub struct FuturesReader<T> {
+        inner: T,
+    }
 
-            impl<T: $trait> crate::decoder::SeqRead for $name<T> {
-                fn poll_seq_read(
-                    self: Pin<&mut Self>,
-                    cx: &mut Context,
-                    buf: &mut [u8],
-                ) -> Poll<io::Result<usize>> {
-                    unsafe {
-                        self.map_unchecked_mut(|this| &mut this.inner)
-                            .poll_read(cx, buf)
-                    }
-                }
+    impl<T: futures::io::AsyncRead> FuturesReader<T> {
+        pub fn new(inner: T) -> Self {
+            Self { inner }
+        }
+    }
+
+    impl<T: futures::io::AsyncRead> crate::decoder::SeqRead for FuturesReader<T> {
+        fn poll_seq_read(
+            self: Pin<&mut Self>,
+            cx: &mut Context,
+            buf: &mut [u8],
+        ) -> Poll<io::Result<usize>> {
+            unsafe {
+                self.map_unchecked_mut(|this| &mut this.inner)
+                    .poll_read(cx, buf)
             }
         }
-        #[cfg( $($attr)+ )]
-        pub use $mod::$name;
     }
 }
 
-async_io_impl! {
-    #[cfg(feature = "futures-io")]
-    mod fut {
-        /// Read adapter for `futures::io::AsyncRead`.
-        FuturesReader : futures::io::AsyncRead;
+#[cfg(feature = "futures-io")]
+use fut::FuturesReader;
+
+#[cfg(feature = "tokio-io")]
+mod tok {
+    use std::io;
+    use std::pin::Pin;
+    use std::task::{Context, Poll};
+
+    /// Read adapter for `futures::io::AsyncRead`
+    pub struct TokioReader<T> {
+        inner: T,
     }
-}
 
-async_io_impl! {
-    #[cfg(feature = "tokio-io")]
-    mod tok {
-        /// Read adapter for `tokio::io::AsyncRead`.
-        TokioReader : tokio::io::AsyncRead;
+    impl<T: tokio::io::AsyncRead> TokioReader<T> {
+        pub fn new(inner: T) -> Self {
+            Self { inner }
+        }
+    }
+
+    impl<T: tokio::io::AsyncRead> crate::decoder::SeqRead for TokioReader<T> {
+        fn poll_seq_read(
+            self: Pin<&mut Self>,
+            cx: &mut Context,
+            buf: &mut [u8],
+        ) -> Poll<io::Result<usize>> {
+            let mut read_buf = tokio::io::ReadBuf::new(buf);
+            unsafe {
+                self.map_unchecked_mut(|this| &mut this.inner)
+                    .poll_read(cx, &mut read_buf)
+                    .map_ok(|_| read_buf.filled().len())
+            }
+        }
     }
 }
+
+#[cfg(feature = "tokio-io")]
+use tok::TokioReader;
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [RFC pxar 2/3] clippy: use matches! instead of match
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (17 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [PATCH pxar 1/3] " Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 13:58 ` [pbs-devel] [RFC pxar 3/3] remove futures-io feature Fabian Grünbichler
  2021-01-12 14:52 ` [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Wolfgang Bumiller
  20 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/lib.rs  | 25 +++++--------------------
 src/util.rs |  7 ++-----
 2 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs
index 4036fd6..ba707da 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -453,42 +453,27 @@ impl Entry {
 impl Entry {
     /// Check whether this is a directory.
     pub fn is_dir(&self) -> bool {
-        match self.kind {
-            EntryKind::Directory { .. } => true,
-            _ => false,
-        }
+        matches!(self.kind, EntryKind::Directory)
     }
 
     /// Check whether this is a symbolic link.
     pub fn is_symlink(&self) -> bool {
-        match self.kind {
-            EntryKind::Symlink(_) => true,
-            _ => false,
-        }
+        matches!(self.kind, EntryKind::Symlink(_))
     }
 
     /// Check whether this is a hard link.
     pub fn is_hardlink(&self) -> bool {
-        match self.kind {
-            EntryKind::Hardlink(_) => true,
-            _ => false,
-        }
+        matches!(self.kind, EntryKind::Hardlink(_))
     }
 
     /// Check whether this is a device node.
     pub fn is_device(&self) -> bool {
-        match self.kind {
-            EntryKind::Device(_) => true,
-            _ => false,
-        }
+        matches!(self.kind, EntryKind::Device(_))
     }
 
     /// Check whether this is a regular file.
     pub fn is_regular_file(&self) -> bool {
-        match self.kind {
-            EntryKind::File { .. } => true,
-            _ => false,
-        }
+        matches!(self.kind, EntryKind::File { .. })
     }
 
     /// Get the file size if this is a regular file, or `None`.
diff --git a/src/util.rs b/src/util.rs
index 652008b..5740963 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -55,8 +55,7 @@ mod consts {
 }
 
 pub fn is_virtual_file_system(magic: i64) -> bool {
-    match magic {
-        consts::BINFMTFS_MAGIC
+    matches!(magic, consts::BINFMTFS_MAGIC
         | consts::CGROUP2_SUPER_MAGIC
         | consts::CGROUP_SUPER_MAGIC
         | consts::CONFIGFS_MAGIC
@@ -73,9 +72,7 @@ pub fn is_virtual_file_system(magic: i64) -> bool {
         | consts::SECURITYFS_MAGIC
         | consts::SELINUX_MAGIC
         | consts::SMACK_MAGIC
-        | consts::SYSFS_MAGIC => true,
-        _ => false,
-    }
+        | consts::SYSFS_MAGIC)
 }
 
 /// Helper function to extract file names from binary archive.
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [RFC pxar 3/3] remove futures-io feature
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (18 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [RFC pxar 2/3] clippy: use matches! instead of match Fabian Grünbichler
@ 2021-01-12 13:58 ` Fabian Grünbichler
  2021-01-12 14:42   ` Wolfgang Bumiller
  2021-01-12 14:52 ` [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Wolfgang Bumiller
  20 siblings, 1 reply; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-12 13:58 UTC (permalink / raw)
  To: pbs-devel

we don't use it, and it adds unnecessary duplication/complexity.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---

Notes:
    I am not particularly fond of FileContents::poll_read scaling the buffer Vec
    like that..

 Cargo.toml          |   6 +--
 debian/control      |  78 ++++++++++----------------------
 src/accessor/aio.rs |  42 ++++-------------
 src/decoder/aio.rs  | 108 --------------------------------------------
 src/encoder/aio.rs  |  81 ---------------------------------
 src/encoder/mod.rs  |  21 ++-------
 6 files changed, 37 insertions(+), 299 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 875de7a..703525e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -53,16 +53,14 @@ tokio = { version = "1.0", optional = true, default-features = false }
 libc = "0.2"
 
 [features]
-default = [ "futures-io", "tokio-io" ]
-futures-io = [ "futures" ]
+default = [ "tokio-io" ]
 tokio-io = [ "tokio" ]
 tokio-fs = [ "tokio-io", "tokio/fs" ]
 
-full = [ "tokio-fs", "futures-io" ]
+full = [ "tokio-fs"]
 
 async-example = [
     "anyhow",
-    "futures-io",
     "tokio-io",
     "tokio-fs",
     "tokio/rt-multi-thread",
diff --git a/debian/control b/debian/control
index 0409da8..dbbd0d6 100644
--- a/debian/control
+++ b/debian/control
@@ -9,10 +9,9 @@ Build-Depends: debhelper (>= 11),
  librust-bitflags-1+default-dev (>= 1.2.1-~~) <!nocheck>,
  librust-endian-trait-0.6+arrays-dev <!nocheck>,
  librust-endian-trait-0.6+default-dev <!nocheck>,
- librust-futures-0.3+default-dev (>= 0.3.1-~~) <!nocheck>,
  librust-libc-0.2+default-dev <!nocheck>,
  librust-siphasher-0.3+default-dev <!nocheck>,
- librust-tokio-0.2-dev (>= 0.2.10-~~) <!nocheck>
+ librust-tokio-1-dev <!nocheck>
 Maintainer: Proxmox Support Team <support@proxmox.com>
 Standards-Version: 4.4.1
 Vcs-Git: 
@@ -29,13 +28,11 @@ Depends:
  librust-libc-0.2+default-dev,
  librust-siphasher-0.3+default-dev
 Recommends:
- librust-pxar+default-dev (= ${binary:Version})
+ librust-pxar+tokio-dev (= ${binary:Version})
 Suggests:
  librust-pxar+anyhow-dev (= ${binary:Version}),
  librust-pxar+async-example-dev (= ${binary:Version}),
- librust-pxar+full-dev (= ${binary:Version}),
  librust-pxar+futures-dev (= ${binary:Version}),
- librust-pxar+tokio-dev (= ${binary:Version}),
  librust-pxar+tokio-fs-dev (= ${binary:Version})
 Provides:
  librust-pxar+test-harness-dev (= ${binary:Version}),
@@ -70,13 +67,11 @@ Multi-Arch: same
 Depends:
  ${misc:Depends},
  librust-pxar-dev (= ${binary:Version}),
- librust-pxar+futures-io-dev (= ${binary:Version}),
  librust-pxar+tokio-io-dev (= ${binary:Version}),
  librust-pxar+tokio-fs-dev (= ${binary:Version}),
  librust-anyhow-1+default-dev,
- librust-tokio-0.2+io-driver-dev (>= 0.2.10-~~),
- librust-tokio-0.2+macros-dev (>= 0.2.10-~~),
- librust-tokio-0.2+rt-threaded-dev (>= 0.2.10-~~)
+ librust-tokio-1+macros-dev,
+ librust-tokio-1+rt-multi-thread-dev
 Provides:
  librust-pxar-0+async-example-dev (= ${binary:Version}),
  librust-pxar-0.6+async-example-dev (= ${binary:Version}),
@@ -85,38 +80,6 @@ Description: Proxmox Archive format support library - feature "async-example"
  This metapackage enables feature "async-example" for the Rust pxar crate, by
  pulling in any additional dependencies needed by that feature.
 
-Package: librust-pxar+default-dev
-Architecture: any
-Multi-Arch: same
-Depends:
- ${misc:Depends},
- librust-pxar-dev (= ${binary:Version}),
- librust-pxar+futures-io-dev (= ${binary:Version}),
- librust-pxar+tokio-io-dev (= ${binary:Version})
-Provides:
- librust-pxar-0+default-dev (= ${binary:Version}),
- librust-pxar-0.6+default-dev (= ${binary:Version}),
- librust-pxar-0.6.2+default-dev (= ${binary:Version})
-Description: Proxmox Archive format support library - feature "default"
- This metapackage enables feature "default" for the Rust pxar crate, by pulling
- in any additional dependencies needed by that feature.
-
-Package: librust-pxar+full-dev
-Architecture: any
-Multi-Arch: same
-Depends:
- ${misc:Depends},
- librust-pxar-dev (= ${binary:Version}),
- librust-pxar+tokio-fs-dev (= ${binary:Version}),
- librust-pxar+futures-io-dev (= ${binary:Version})
-Provides:
- librust-pxar-0+full-dev (= ${binary:Version}),
- librust-pxar-0.6+full-dev (= ${binary:Version}),
- librust-pxar-0.6.2+full-dev (= ${binary:Version})
-Description: Proxmox Archive format support library - feature "full"
- This metapackage enables feature "full" for the Rust pxar crate, by pulling in
- any additional dependencies needed by that feature.
-
 Package: librust-pxar+futures-dev
 Architecture: any
 Multi-Arch: same
@@ -125,18 +88,12 @@ Depends:
  librust-pxar-dev (= ${binary:Version}),
  librust-futures-0.3+default-dev (>= 0.3.1-~~)
 Provides:
- librust-pxar+futures-io-dev (= ${binary:Version}),
  librust-pxar-0+futures-dev (= ${binary:Version}),
- librust-pxar-0+futures-io-dev (= ${binary:Version}),
  librust-pxar-0.6+futures-dev (= ${binary:Version}),
- librust-pxar-0.6+futures-io-dev (= ${binary:Version}),
- librust-pxar-0.6.2+futures-dev (= ${binary:Version}),
- librust-pxar-0.6.2+futures-io-dev (= ${binary:Version})
-Description: Proxmox Archive format support library - feature "futures" and 1 more
+ librust-pxar-0.6.2+futures-dev (= ${binary:Version})
+Description: Proxmox Archive format support library - feature "futures"
  This metapackage enables feature "futures" for the Rust pxar crate, by pulling
  in any additional dependencies needed by that feature.
- .
- Additionally, this package also provides the "futures-io" feature.
 
 Package: librust-pxar+tokio-dev
 Architecture: any
@@ -144,20 +101,25 @@ Multi-Arch: same
 Depends:
  ${misc:Depends},
  librust-pxar-dev (= ${binary:Version}),
- librust-tokio-0.2-dev (>= 0.2.10-~~)
+ librust-tokio-1-dev
 Provides:
+ librust-pxar+default-dev (= ${binary:Version}),
  librust-pxar+tokio-io-dev (= ${binary:Version}),
  librust-pxar-0+tokio-dev (= ${binary:Version}),
+ librust-pxar-0+default-dev (= ${binary:Version}),
  librust-pxar-0+tokio-io-dev (= ${binary:Version}),
  librust-pxar-0.6+tokio-dev (= ${binary:Version}),
+ librust-pxar-0.6+default-dev (= ${binary:Version}),
  librust-pxar-0.6+tokio-io-dev (= ${binary:Version}),
  librust-pxar-0.6.2+tokio-dev (= ${binary:Version}),
+ librust-pxar-0.6.2+default-dev (= ${binary:Version}),
  librust-pxar-0.6.2+tokio-io-dev (= ${binary:Version})
-Description: Proxmox Archive format support library - feature "tokio" and 1 more
+Description: Proxmox Archive format support library - feature "tokio" and 2 more
  This metapackage enables feature "tokio" for the Rust pxar crate, by pulling in
  any additional dependencies needed by that feature.
  .
- Additionally, this package also provides the "tokio-io" feature.
+ Additionally, this package also provides the "default", and "tokio-io"
+ features.
 
 Package: librust-pxar+tokio-fs-dev
 Architecture: any
@@ -166,11 +128,17 @@ Depends:
  ${misc:Depends},
  librust-pxar-dev (= ${binary:Version}),
  librust-pxar+tokio-io-dev (= ${binary:Version}),
- librust-tokio-0.2+fs-dev (>= 0.2.10-~~)
+ librust-tokio-1+fs-dev
 Provides:
+ librust-pxar+full-dev (= ${binary:Version}),
  librust-pxar-0+tokio-fs-dev (= ${binary:Version}),
+ librust-pxar-0+full-dev (= ${binary:Version}),
  librust-pxar-0.6+tokio-fs-dev (= ${binary:Version}),
- librust-pxar-0.6.2+tokio-fs-dev (= ${binary:Version})
-Description: Proxmox Archive format support library - feature "tokio-fs"
+ librust-pxar-0.6+full-dev (= ${binary:Version}),
+ librust-pxar-0.6.2+tokio-fs-dev (= ${binary:Version}),
+ librust-pxar-0.6.2+full-dev (= ${binary:Version})
+Description: Proxmox Archive format support library - feature "tokio-fs" and 1 more
  This metapackage enables feature "tokio-fs" for the Rust pxar crate, by pulling
  in any additional dependencies needed by that feature.
+ .
+ Additionally, this package also provides the "full" feature.
diff --git a/src/accessor/aio.rs b/src/accessor/aio.rs
index dd017ae..c48ca8f 100644
--- a/src/accessor/aio.rs
+++ b/src/accessor/aio.rs
@@ -348,20 +348,19 @@ pub struct FileContents<T> {
 unsafe impl<T: Send> Send for FileContents<T> {}
 unsafe impl<T: Sync> Sync for FileContents<T> {}
 
-#[cfg(any(feature = "futures-io", feature = "tokio-io"))]
-impl<T: Clone + ReadAt> FileContents<T> {
-    /// Similar implementation exists for SeqReadAtAdapter in mod.rs
-    fn do_poll_read(
+#[cfg(feature = "tokio-io")]
+impl<T: Clone + ReadAt> tokio::io::AsyncRead for FileContents<T> {
+    fn poll_read(
         self: Pin<&mut Self>,
         cx: &mut Context,
-        dest: &mut [u8],
-    ) -> Poll<io::Result<usize>> {
+        dest: &mut tokio::io::ReadBuf,
+    ) -> Poll<io::Result<()>> {
         let this = unsafe { Pin::into_inner_unchecked(self) };
         loop {
             match this.future.take() {
                 None => {
                     let mut buffer = mem::take(&mut this.buffer);
-                    util::scale_read_buffer(&mut buffer, dest.len());
+                    util::scale_read_buffer(&mut buffer, dest.remaining());
                     let reader: accessor::FileContentsImpl<T> = this.inner.clone();
                     let at = this.at;
                     let future: Pin<Box<dyn Future<Output = io::Result<ReadResult>>>> =
@@ -384,9 +383,9 @@ impl<T: Clone + ReadAt> FileContents<T> {
                     Poll::Ready(Ok(ReadResult { len: got, buffer })) => {
                         this.buffer = buffer;
                         this.at += got as u64;
-                        let len = got.min(dest.len());
-                        dest[..len].copy_from_slice(&this.buffer[..len]);
-                        return Poll::Ready(Ok(len));
+                        let len = got.min(dest.remaining());
+                        dest.put_slice(&this.buffer[..len]);
+                        return Poll::Ready(Ok(()));
                     }
                 },
             }
@@ -394,29 +393,6 @@ impl<T: Clone + ReadAt> FileContents<T> {
     }
 }
 
-#[cfg(feature = "futures-io")]
-impl<T: Clone + ReadAt> futures::io::AsyncRead for FileContents<T> {
-    fn poll_read(
-        self: Pin<&mut Self>,
-        cx: &mut Context,
-        buf: &mut [u8],
-    ) -> Poll<io::Result<usize>> {
-        Self::do_poll_read(self, cx, buf)
-    }
-}
-
-#[cfg(feature = "tokio-io")]
-impl<T: Clone + ReadAt> tokio::io::AsyncRead for FileContents<T> {
-    fn poll_read(
-        self: Pin<&mut Self>,
-        cx: &mut Context,
-        buf: &mut tokio::io::ReadBuf,
-    ) -> Poll<io::Result<()>> {
-        Self::do_poll_read(self, cx, &mut buf.initialize_unfilled())
-            .map_ok(|bytes| { buf.set_filled(bytes); () })
-    }
-}
-
 impl<T: Clone + ReadAt> ReadAt for FileContents<T> {
     fn start_read_at<'a>(
         self: Pin<&'a Self>,
diff --git a/src/decoder/aio.rs b/src/decoder/aio.rs
index 1a5f5ea..82030b0 100644
--- a/src/decoder/aio.rs
+++ b/src/decoder/aio.rs
@@ -16,15 +16,6 @@ pub struct Decoder<T> {
     inner: decoder::DecoderImpl<T>,
 }
 
-#[cfg(feature = "futures-io")]
-impl<T: futures::io::AsyncRead> Decoder<FuturesReader<T>> {
-    /// Decode a `pxar` archive from a `futures::io::AsyncRead` input.
-    #[inline]
-    pub async fn from_futures(input: T) -> io::Result<Self> {
-        Decoder::new(FuturesReader::new(input)).await
-    }
-}
-
 #[cfg(feature = "tokio-io")]
 impl<T: tokio::io::AsyncRead> Decoder<TokioReader<T>> {
     /// Decode a `pxar` archive from a `tokio::io::AsyncRead` input.
@@ -69,107 +60,8 @@ impl<T: SeqRead> Decoder<T> {
     pub fn enable_goodbye_entries(&mut self, on: bool) {
         self.inner.with_goodbye_tables = on;
     }
-
-    /// Turn this decoder into a `Stream`.
-    #[cfg(feature = "futures-io")]
-    pub fn into_stream(self) -> DecoderStream<T> {
-        DecoderStream::new(self)
-    }
-}
-
-#[cfg(feature = "futures-io")]
-mod stream {
-    use std::future::Future;
-    use std::io;
-    use std::pin::Pin;
-    use std::task::{Context, Poll};
-
-    use super::{Entry, SeqRead};
-
-    /// A wrapper for the async decoder implementing `futures::stream::Stream`.
-    ///
-    /// As long as streams are poll-based this wrapper is required to turn `async fn next()` into
-    /// `Stream`'s `poll_next()` interface.
-    #[allow(clippy::type_complexity)] // yeah no
-    pub struct DecoderStream<T> {
-        inner: super::Decoder<T>,
-        future: Option<Pin<Box<dyn Future<Output = Option<io::Result<Entry>>>>>>,
-    }
-
-    impl<T> DecoderStream<T> {
-        pub fn new(inner: super::Decoder<T>) -> Self {
-            Self {
-                inner,
-                future: None,
-            }
-        }
-    }
-
-    impl<T: SeqRead> futures::stream::Stream for DecoderStream<T> {
-        type Item = io::Result<Entry>;
-
-        fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
-            let this = unsafe { self.get_unchecked_mut() };
-            loop {
-                if let Some(mut fut) = this.future.take() {
-                    match fut.as_mut().poll(cx) {
-                        Poll::Ready(res) => return Poll::Ready(res),
-                        Poll::Pending => {
-                            this.future = Some(fut);
-                            return Poll::Pending;
-                        }
-                    }
-                }
-                unsafe {
-                    let fut: Box<dyn Future<Output = _>> = Box::new(this.inner.next());
-                    // Discard the lifetime:
-                    let fut: *mut (dyn Future<Output = Option<io::Result<Entry>>> + 'static) =
-                        core::mem::transmute(Box::into_raw(fut));
-                    let fut = Box::from_raw(fut);
-                    this.future = Some(Pin::new_unchecked(fut));
-                }
-            }
-        }
-    }
-}
-
-#[cfg(feature = "futures-io")]
-pub use stream::DecoderStream;
-
-#[cfg(feature = "futures-io")]
-mod fut {
-    use std::io;
-    use std::pin::Pin;
-    use std::task::{Context, Poll};
-
-    /// Read adapter for `futures::io::AsyncRead`
-    pub struct FuturesReader<T> {
-        inner: T,
-    }
-
-    impl<T: futures::io::AsyncRead> FuturesReader<T> {
-        pub fn new(inner: T) -> Self {
-            Self { inner }
-        }
-    }
-
-    impl<T: futures::io::AsyncRead> crate::decoder::SeqRead for FuturesReader<T> {
-        fn poll_seq_read(
-            self: Pin<&mut Self>,
-            cx: &mut Context,
-            buf: &mut [u8],
-        ) -> Poll<io::Result<usize>> {
-            unsafe {
-                self.map_unchecked_mut(|this| &mut this.inner)
-                    .poll_read(cx, buf)
-            }
-        }
-    }
 }
 
-#[cfg(feature = "futures-io")]
-use fut::FuturesReader;
-
 #[cfg(feature = "tokio-io")]
 mod tok {
     use std::io;
diff --git a/src/encoder/aio.rs b/src/encoder/aio.rs
index d989abd..908e019 100644
--- a/src/encoder/aio.rs
+++ b/src/encoder/aio.rs
@@ -9,11 +9,6 @@ use crate::encoder::{self, LinkOffset, SeqWrite};
 use crate::format;
 use crate::Metadata;
 
-// #[cfg(feature = "futures-io")]
-// use crate::decoder::aio::FuturesReader;
-// #[cfg(feature = "tokio-io")]
-// use crate::decoder::aio::TokioReader;
-
 /// Asynchronous `pxar` encoder.
 ///
 /// This is the `async` version of the `pxar` encoder.
@@ -22,18 +17,6 @@ pub struct Encoder<'a, T: SeqWrite + 'a> {
     inner: encoder::EncoderImpl<'a, T>,
 }
 
-#[cfg(feature = "futures-io")]
-impl<'a, T: futures::io::AsyncWrite + 'a> Encoder<'a, FuturesWriter<T>> {
-    /// Encode a `pxar` archive into a `futures::io::AsyncWrite` output.
-    #[inline]
-    pub async fn from_futures(
-        output: T,
-        metadata: &Metadata,
-    ) -> io::Result<Encoder<'a, FuturesWriter<T>>> {
-        Encoder::new(FuturesWriter::new(output), metadata).await
-    }
-}
-
 #[cfg(feature = "tokio-io")]
 impl<'a, T: tokio::io::AsyncWrite + 'a> Encoder<'a, TokioWriter<T>> {
     /// Encode a `pxar` archive into a `tokio::io::AsyncWrite` output.
@@ -214,21 +197,6 @@ impl<'a> File<'a> {
     }
 }
 
-#[cfg(feature = "futures-io")]
-impl<'a> futures::io::AsyncWrite for File<'a> {
-    fn poll_write(self: Pin<&mut Self>, cx: &mut Context, data: &[u8]) -> Poll<io::Result<usize>> {
-        unsafe { self.map_unchecked_mut(|this| &mut this.inner) }.poll_write(cx, data)
-    }
-
-    fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
-        unsafe { self.map_unchecked_mut(|this| &mut this.inner) }.poll_flush(cx)
-    }
-
-    fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
-        unsafe { self.map_unchecked_mut(|this| &mut this.inner) }.poll_close(cx)
-    }
-}
-
 #[cfg(feature = "tokio-io")]
 impl<'a> tokio::io::AsyncWrite for File<'a> {
     fn poll_write(self: Pin<&mut Self>, cx: &mut Context, data: &[u8]) -> Poll<io::Result<usize>> {
@@ -244,55 +212,6 @@ impl<'a> tokio::io::AsyncWrite for File<'a> {
     }
 }
 
-/// Pxar encoder write adapter for `futures::io::AsyncWrite`.
-#[cfg(feature = "futures-io")]
-mod futures_writer {
-    use std::io;
-    use std::pin::Pin;
-    use std::task::{Context, Poll};
-
-    use crate::encoder::SeqWrite;
-
-    pub struct FuturesWriter<T> {
-        inner: Option<T>,
-    }
-
-    impl<T: futures::io::AsyncWrite> FuturesWriter<T> {
-        pub fn new(inner: T) -> Self {
-            Self { inner: Some(inner) }
-        }
-
-        fn inner_mut(&mut self) -> io::Result<Pin<&mut T>> {
-            let inner = self
-                .inner
-                .as_mut()
-                .ok_or_else(|| io_format_err!("write after close"))?;
-            Ok(unsafe { Pin::new_unchecked(inner) })
-        }
-
-        fn inner(self: Pin<&mut Self>) -> io::Result<Pin<&mut T>> {
-            unsafe { self.get_unchecked_mut() }.inner_mut()
-        }
-    }
-
-    impl<T: futures::io::AsyncWrite> SeqWrite for FuturesWriter<T> {
-        fn poll_seq_write(
-            self: Pin<&mut Self>,
-            cx: &mut Context,
-            buf: &[u8],
-        ) -> Poll<io::Result<usize>> {
-            let this = unsafe { self.get_unchecked_mut() };
-            this.inner_mut()?.poll_write(cx, buf)
-        }
-
-        fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
-            self.inner()?.poll_flush(cx)
-        }
-    }
-}
-
-pub use futures_writer::FuturesWriter;
-
 /// Pxar encoder write adapter for `tokio::io::AsyncWrite`.
 #[cfg(feature = "tokio-io")]
 mod tokio_writer {
diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs
index f186aa8..fdd04ae 100644
--- a/src/encoder/mod.rs
+++ b/src/encoder/mod.rs
@@ -818,7 +818,7 @@ impl<'a> FileImpl<'a> {
     }
 
     /// Poll write interface to more easily connect to tokio/futures.
-    #[cfg(any(feature = "tokio-io", feature = "futures-io"))]
+    #[cfg(feature = "tokio-io")]
     pub fn poll_write(
         self: Pin<&mut Self>,
         cx: &mut Context,
@@ -838,7 +838,7 @@ impl<'a> FileImpl<'a> {
     }
 
     /// Poll flush interface to more easily connect to tokio/futures.
-    #[cfg(any(feature = "tokio-io", feature = "futures-io"))]
+    #[cfg(feature = "tokio-io")]
     pub fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
         unsafe {
             self.map_unchecked_mut(|this| &mut this.output)
@@ -850,7 +850,7 @@ impl<'a> FileImpl<'a> {
     ///
     /// This just calls flush, though, since we're just a virtual writer writing to the file
     /// provided by our encoder.
-    #[cfg(any(feature = "tokio-io", feature = "futures-io"))]
+    #[cfg(feature = "tokio-io")]
     pub fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
         unsafe {
             self.map_unchecked_mut(|this| &mut this.output)
@@ -897,18 +897,3 @@ impl<'a> tokio::io::AsyncWrite for FileImpl<'a> {
         FileImpl::poll_close(self, cx)
     }
 }
-
-#[cfg(feature = "futures-io")]
-impl<'a> futures::io::AsyncWrite for FileImpl<'a> {
-    fn poll_write(self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll<io::Result<usize>> {
-        FileImpl::poll_write(self, cx, buf)
-    }
-
-    fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
-        FileImpl::poll_flush(self, cx)
-    }
-
-    fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
-        FileImpl::poll_close(self, cx)
-    }
-}
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [pbs-devel] [RFC pxar 3/3] remove futures-io feature
  2021-01-12 13:58 ` [pbs-devel] [RFC pxar 3/3] remove futures-io feature Fabian Grünbichler
@ 2021-01-12 14:42   ` Wolfgang Bumiller
  0 siblings, 0 replies; 29+ messages in thread
From: Wolfgang Bumiller @ 2021-01-12 14:42 UTC (permalink / raw)
  To: Fabian Grünbichler; +Cc: pbs-devel

The `futures` crate also contains the `Stream` trait which was also
covered by the `futures-io` feature.

Rather than removing `DecoderStream` and `into_decoder` those two should
probably be a `stream` feature now.

Btw. `cargo test` needs to be run `--all-features` (`make check` does
it btw.). This currently fails due to the missing stream part.

On Tue, Jan 12, 2021 at 02:58:30PM +0100, Fabian Grünbichler wrote:
> we don't use it, and it adds unnecessary duplication/complexity.
> 
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
> 
> Notes:
>     I am not particularly fond of FileContents::poll_read scaling the buffer Vec
>     like that..
> 
>  Cargo.toml          |   6 +--
>  debian/control      |  78 ++++++++++----------------------
>  src/accessor/aio.rs |  42 ++++-------------
>  src/decoder/aio.rs  | 108 --------------------------------------------
>  src/encoder/aio.rs  |  81 ---------------------------------
>  src/encoder/mod.rs  |  21 ++-------
>  6 files changed, 37 insertions(+), 299 deletions(-)
> 
> diff --git a/Cargo.toml b/Cargo.toml
> index 875de7a..703525e 100644
> --- a/Cargo.toml
> +++ b/Cargo.toml
> @@ -53,16 +53,14 @@ tokio = { version = "1.0", optional = true, default-features = false }
>  libc = "0.2"
>  
>  [features]
> -default = [ "futures-io", "tokio-io" ]
> -futures-io = [ "futures" ]
> +default = [ "tokio-io" ]
>  tokio-io = [ "tokio" ]
>  tokio-fs = [ "tokio-io", "tokio/fs" ]
>  
> -full = [ "tokio-fs", "futures-io" ]
> +full = [ "tokio-fs"]
>  
>  async-example = [
>      "anyhow",
> -    "futures-io",
>      "tokio-io",
>      "tokio-fs",
>      "tokio/rt-multi-thread",
> diff --git a/debian/control b/debian/control
> index 0409da8..dbbd0d6 100644
> --- a/debian/control
> +++ b/debian/control
> @@ -9,10 +9,9 @@ Build-Depends: debhelper (>= 11),
>   librust-bitflags-1+default-dev (>= 1.2.1-~~) <!nocheck>,
>   librust-endian-trait-0.6+arrays-dev <!nocheck>,
>   librust-endian-trait-0.6+default-dev <!nocheck>,
> - librust-futures-0.3+default-dev (>= 0.3.1-~~) <!nocheck>,
>   librust-libc-0.2+default-dev <!nocheck>,
>   librust-siphasher-0.3+default-dev <!nocheck>,
> - librust-tokio-0.2-dev (>= 0.2.10-~~) <!nocheck>
> + librust-tokio-1-dev <!nocheck>
>  Maintainer: Proxmox Support Team <support@proxmox.com>
>  Standards-Version: 4.4.1
>  Vcs-Git: 
> @@ -29,13 +28,11 @@ Depends:
>   librust-libc-0.2+default-dev,
>   librust-siphasher-0.3+default-dev
>  Recommends:
> - librust-pxar+default-dev (= ${binary:Version})
> + librust-pxar+tokio-dev (= ${binary:Version})
>  Suggests:
>   librust-pxar+anyhow-dev (= ${binary:Version}),
>   librust-pxar+async-example-dev (= ${binary:Version}),
> - librust-pxar+full-dev (= ${binary:Version}),
>   librust-pxar+futures-dev (= ${binary:Version}),
> - librust-pxar+tokio-dev (= ${binary:Version}),
>   librust-pxar+tokio-fs-dev (= ${binary:Version})
>  Provides:
>   librust-pxar+test-harness-dev (= ${binary:Version}),
> @@ -70,13 +67,11 @@ Multi-Arch: same
>  Depends:
>   ${misc:Depends},
>   librust-pxar-dev (= ${binary:Version}),
> - librust-pxar+futures-io-dev (= ${binary:Version}),
>   librust-pxar+tokio-io-dev (= ${binary:Version}),
>   librust-pxar+tokio-fs-dev (= ${binary:Version}),
>   librust-anyhow-1+default-dev,
> - librust-tokio-0.2+io-driver-dev (>= 0.2.10-~~),
> - librust-tokio-0.2+macros-dev (>= 0.2.10-~~),
> - librust-tokio-0.2+rt-threaded-dev (>= 0.2.10-~~)
> + librust-tokio-1+macros-dev,
> + librust-tokio-1+rt-multi-thread-dev
>  Provides:
>   librust-pxar-0+async-example-dev (= ${binary:Version}),
>   librust-pxar-0.6+async-example-dev (= ${binary:Version}),
> @@ -85,38 +80,6 @@ Description: Proxmox Archive format support library - feature "async-example"
>   This metapackage enables feature "async-example" for the Rust pxar crate, by
>   pulling in any additional dependencies needed by that feature.
>  
> -Package: librust-pxar+default-dev
> -Architecture: any
> -Multi-Arch: same
> -Depends:
> - ${misc:Depends},
> - librust-pxar-dev (= ${binary:Version}),
> - librust-pxar+futures-io-dev (= ${binary:Version}),
> - librust-pxar+tokio-io-dev (= ${binary:Version})
> -Provides:
> - librust-pxar-0+default-dev (= ${binary:Version}),
> - librust-pxar-0.6+default-dev (= ${binary:Version}),
> - librust-pxar-0.6.2+default-dev (= ${binary:Version})
> -Description: Proxmox Archive format support library - feature "default"
> - This metapackage enables feature "default" for the Rust pxar crate, by pulling
> - in any additional dependencies needed by that feature.
> -
> -Package: librust-pxar+full-dev
> -Architecture: any
> -Multi-Arch: same
> -Depends:
> - ${misc:Depends},
> - librust-pxar-dev (= ${binary:Version}),
> - librust-pxar+tokio-fs-dev (= ${binary:Version}),
> - librust-pxar+futures-io-dev (= ${binary:Version})
> -Provides:
> - librust-pxar-0+full-dev (= ${binary:Version}),
> - librust-pxar-0.6+full-dev (= ${binary:Version}),
> - librust-pxar-0.6.2+full-dev (= ${binary:Version})
> -Description: Proxmox Archive format support library - feature "full"
> - This metapackage enables feature "full" for the Rust pxar crate, by pulling in
> - any additional dependencies needed by that feature.
> -
>  Package: librust-pxar+futures-dev
>  Architecture: any
>  Multi-Arch: same
> @@ -125,18 +88,12 @@ Depends:
>   librust-pxar-dev (= ${binary:Version}),
>   librust-futures-0.3+default-dev (>= 0.3.1-~~)
>  Provides:
> - librust-pxar+futures-io-dev (= ${binary:Version}),
>   librust-pxar-0+futures-dev (= ${binary:Version}),
> - librust-pxar-0+futures-io-dev (= ${binary:Version}),
>   librust-pxar-0.6+futures-dev (= ${binary:Version}),
> - librust-pxar-0.6+futures-io-dev (= ${binary:Version}),
> - librust-pxar-0.6.2+futures-dev (= ${binary:Version}),
> - librust-pxar-0.6.2+futures-io-dev (= ${binary:Version})
> -Description: Proxmox Archive format support library - feature "futures" and 1 more
> + librust-pxar-0.6.2+futures-dev (= ${binary:Version})
> +Description: Proxmox Archive format support library - feature "futures"
>   This metapackage enables feature "futures" for the Rust pxar crate, by pulling
>   in any additional dependencies needed by that feature.
> - .
> - Additionally, this package also provides the "futures-io" feature.
>  
>  Package: librust-pxar+tokio-dev
>  Architecture: any
> @@ -144,20 +101,25 @@ Multi-Arch: same
>  Depends:
>   ${misc:Depends},
>   librust-pxar-dev (= ${binary:Version}),
> - librust-tokio-0.2-dev (>= 0.2.10-~~)
> + librust-tokio-1-dev
>  Provides:
> + librust-pxar+default-dev (= ${binary:Version}),
>   librust-pxar+tokio-io-dev (= ${binary:Version}),
>   librust-pxar-0+tokio-dev (= ${binary:Version}),
> + librust-pxar-0+default-dev (= ${binary:Version}),
>   librust-pxar-0+tokio-io-dev (= ${binary:Version}),
>   librust-pxar-0.6+tokio-dev (= ${binary:Version}),
> + librust-pxar-0.6+default-dev (= ${binary:Version}),
>   librust-pxar-0.6+tokio-io-dev (= ${binary:Version}),
>   librust-pxar-0.6.2+tokio-dev (= ${binary:Version}),
> + librust-pxar-0.6.2+default-dev (= ${binary:Version}),
>   librust-pxar-0.6.2+tokio-io-dev (= ${binary:Version})
> -Description: Proxmox Archive format support library - feature "tokio" and 1 more
> +Description: Proxmox Archive format support library - feature "tokio" and 2 more
>   This metapackage enables feature "tokio" for the Rust pxar crate, by pulling in
>   any additional dependencies needed by that feature.
>   .
> - Additionally, this package also provides the "tokio-io" feature.
> + Additionally, this package also provides the "default", and "tokio-io"
> + features.
>  
>  Package: librust-pxar+tokio-fs-dev
>  Architecture: any
> @@ -166,11 +128,17 @@ Depends:
>   ${misc:Depends},
>   librust-pxar-dev (= ${binary:Version}),
>   librust-pxar+tokio-io-dev (= ${binary:Version}),
> - librust-tokio-0.2+fs-dev (>= 0.2.10-~~)
> + librust-tokio-1+fs-dev
>  Provides:
> + librust-pxar+full-dev (= ${binary:Version}),
>   librust-pxar-0+tokio-fs-dev (= ${binary:Version}),
> + librust-pxar-0+full-dev (= ${binary:Version}),
>   librust-pxar-0.6+tokio-fs-dev (= ${binary:Version}),
> - librust-pxar-0.6.2+tokio-fs-dev (= ${binary:Version})
> -Description: Proxmox Archive format support library - feature "tokio-fs"
> + librust-pxar-0.6+full-dev (= ${binary:Version}),
> + librust-pxar-0.6.2+tokio-fs-dev (= ${binary:Version}),
> + librust-pxar-0.6.2+full-dev (= ${binary:Version})
> +Description: Proxmox Archive format support library - feature "tokio-fs" and 1 more
>   This metapackage enables feature "tokio-fs" for the Rust pxar crate, by pulling
>   in any additional dependencies needed by that feature.
> + .
> + Additionally, this package also provides the "full" feature.
> diff --git a/src/accessor/aio.rs b/src/accessor/aio.rs
> index dd017ae..c48ca8f 100644
> --- a/src/accessor/aio.rs
> +++ b/src/accessor/aio.rs
> @@ -348,20 +348,19 @@ pub struct FileContents<T> {
>  unsafe impl<T: Send> Send for FileContents<T> {}
>  unsafe impl<T: Sync> Sync for FileContents<T> {}
>  
> -#[cfg(any(feature = "futures-io", feature = "tokio-io"))]
> -impl<T: Clone + ReadAt> FileContents<T> {
> -    /// Similar implementation exists for SeqReadAtAdapter in mod.rs
> -    fn do_poll_read(
> +#[cfg(feature = "tokio-io")]
> +impl<T: Clone + ReadAt> tokio::io::AsyncRead for FileContents<T> {
> +    fn poll_read(
>          self: Pin<&mut Self>,
>          cx: &mut Context,
> -        dest: &mut [u8],
> -    ) -> Poll<io::Result<usize>> {
> +        dest: &mut tokio::io::ReadBuf,
> +    ) -> Poll<io::Result<()>> {
>          let this = unsafe { Pin::into_inner_unchecked(self) };
>          loop {
>              match this.future.take() {
>                  None => {
>                      let mut buffer = mem::take(&mut this.buffer);
> -                    util::scale_read_buffer(&mut buffer, dest.len());
> +                    util::scale_read_buffer(&mut buffer, dest.remaining());
>                      let reader: accessor::FileContentsImpl<T> = this.inner.clone();
>                      let at = this.at;
>                      let future: Pin<Box<dyn Future<Output = io::Result<ReadResult>>>> =
> @@ -384,9 +383,9 @@ impl<T: Clone + ReadAt> FileContents<T> {
>                      Poll::Ready(Ok(ReadResult { len: got, buffer })) => {
>                          this.buffer = buffer;
>                          this.at += got as u64;
> -                        let len = got.min(dest.len());
> -                        dest[..len].copy_from_slice(&this.buffer[..len]);
> -                        return Poll::Ready(Ok(len));
> +                        let len = got.min(dest.remaining());
> +                        dest.put_slice(&this.buffer[..len]);
> +                        return Poll::Ready(Ok(()));
>                      }
>                  },
>              }
> @@ -394,29 +393,6 @@ impl<T: Clone + ReadAt> FileContents<T> {
>      }
>  }
>  
> -#[cfg(feature = "futures-io")]
> -impl<T: Clone + ReadAt> futures::io::AsyncRead for FileContents<T> {
> -    fn poll_read(
> -        self: Pin<&mut Self>,
> -        cx: &mut Context,
> -        buf: &mut [u8],
> -    ) -> Poll<io::Result<usize>> {
> -        Self::do_poll_read(self, cx, buf)
> -    }
> -}
> -
> -#[cfg(feature = "tokio-io")]
> -impl<T: Clone + ReadAt> tokio::io::AsyncRead for FileContents<T> {
> -    fn poll_read(
> -        self: Pin<&mut Self>,
> -        cx: &mut Context,
> -        buf: &mut tokio::io::ReadBuf,
> -    ) -> Poll<io::Result<()>> {
> -        Self::do_poll_read(self, cx, &mut buf.initialize_unfilled())
> -            .map_ok(|bytes| { buf.set_filled(bytes); () })
> -    }
> -}
> -
>  impl<T: Clone + ReadAt> ReadAt for FileContents<T> {
>      fn start_read_at<'a>(
>          self: Pin<&'a Self>,
> diff --git a/src/decoder/aio.rs b/src/decoder/aio.rs
> index 1a5f5ea..82030b0 100644
> --- a/src/decoder/aio.rs
> +++ b/src/decoder/aio.rs
> @@ -16,15 +16,6 @@ pub struct Decoder<T> {
>      inner: decoder::DecoderImpl<T>,
>  }
>  
> -#[cfg(feature = "futures-io")]
> -impl<T: futures::io::AsyncRead> Decoder<FuturesReader<T>> {
> -    /// Decode a `pxar` archive from a `futures::io::AsyncRead` input.
> -    #[inline]
> -    pub async fn from_futures(input: T) -> io::Result<Self> {
> -        Decoder::new(FuturesReader::new(input)).await
> -    }
> -}
> -
>  #[cfg(feature = "tokio-io")]
>  impl<T: tokio::io::AsyncRead> Decoder<TokioReader<T>> {
>      /// Decode a `pxar` archive from a `tokio::io::AsyncRead` input.
> @@ -69,107 +60,8 @@ impl<T: SeqRead> Decoder<T> {
>      pub fn enable_goodbye_entries(&mut self, on: bool) {
>          self.inner.with_goodbye_tables = on;
>      }
> -
> -    /// Turn this decoder into a `Stream`.
> -    #[cfg(feature = "futures-io")]
> -    pub fn into_stream(self) -> DecoderStream<T> {
> -        DecoderStream::new(self)
> -    }
> -}
> -
> -#[cfg(feature = "futures-io")]
> -mod stream {
> -    use std::future::Future;
> -    use std::io;
> -    use std::pin::Pin;
> -    use std::task::{Context, Poll};
> -
> -    use super::{Entry, SeqRead};
> -
> -    /// A wrapper for the async decoder implementing `futures::stream::Stream`.
> -    ///
> -    /// As long as streams are poll-based this wrapper is required to turn `async fn next()` into
> -    /// `Stream`'s `poll_next()` interface.
> -    #[allow(clippy::type_complexity)] // yeah no
> -    pub struct DecoderStream<T> {
> -        inner: super::Decoder<T>,
> -        future: Option<Pin<Box<dyn Future<Output = Option<io::Result<Entry>>>>>>,
> -    }
> -
> -    impl<T> DecoderStream<T> {
> -        pub fn new(inner: super::Decoder<T>) -> Self {
> -            Self {
> -                inner,
> -                future: None,
> -            }
> -        }
> -    }
> -
> -    impl<T: SeqRead> futures::stream::Stream for DecoderStream<T> {
> -        type Item = io::Result<Entry>;
> -
> -        fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
> -            let this = unsafe { self.get_unchecked_mut() };
> -            loop {
> -                if let Some(mut fut) = this.future.take() {
> -                    match fut.as_mut().poll(cx) {
> -                        Poll::Ready(res) => return Poll::Ready(res),
> -                        Poll::Pending => {
> -                            this.future = Some(fut);
> -                            return Poll::Pending;
> -                        }
> -                    }
> -                }
> -                unsafe {
> -                    let fut: Box<dyn Future<Output = _>> = Box::new(this.inner.next());
> -                    // Discard the lifetime:
> -                    let fut: *mut (dyn Future<Output = Option<io::Result<Entry>>> + 'static) =
> -                        core::mem::transmute(Box::into_raw(fut));
> -                    let fut = Box::from_raw(fut);
> -                    this.future = Some(Pin::new_unchecked(fut));
> -                }
> -            }
> -        }
> -    }
> -}
> -
> -#[cfg(feature = "futures-io")]
> -pub use stream::DecoderStream;
> -
> -#[cfg(feature = "futures-io")]
> -mod fut {
> -    use std::io;
> -    use std::pin::Pin;
> -    use std::task::{Context, Poll};
> -
> -    /// Read adapter for `futures::io::AsyncRead`
> -    pub struct FuturesReader<T> {
> -        inner: T,
> -    }
> -
> -    impl<T: futures::io::AsyncRead> FuturesReader<T> {
> -        pub fn new(inner: T) -> Self {
> -            Self { inner }
> -        }
> -    }
> -
> -    impl<T: futures::io::AsyncRead> crate::decoder::SeqRead for FuturesReader<T> {
> -        fn poll_seq_read(
> -            self: Pin<&mut Self>,
> -            cx: &mut Context,
> -            buf: &mut [u8],
> -        ) -> Poll<io::Result<usize>> {
> -            unsafe {
> -                self.map_unchecked_mut(|this| &mut this.inner)
> -                    .poll_read(cx, buf)
> -            }
> -        }
> -    }
>  }
>  
> -#[cfg(feature = "futures-io")]
> -use fut::FuturesReader;
> -
>  #[cfg(feature = "tokio-io")]
>  mod tok {
>      use std::io;
> diff --git a/src/encoder/aio.rs b/src/encoder/aio.rs
> index d989abd..908e019 100644
> --- a/src/encoder/aio.rs
> +++ b/src/encoder/aio.rs
> @@ -9,11 +9,6 @@ use crate::encoder::{self, LinkOffset, SeqWrite};
>  use crate::format;
>  use crate::Metadata;
>  
> -// #[cfg(feature = "futures-io")]
> -// use crate::decoder::aio::FuturesReader;
> -// #[cfg(feature = "tokio-io")]
> -// use crate::decoder::aio::TokioReader;
> -
>  /// Asynchronous `pxar` encoder.
>  ///
>  /// This is the `async` version of the `pxar` encoder.
> @@ -22,18 +17,6 @@ pub struct Encoder<'a, T: SeqWrite + 'a> {
>      inner: encoder::EncoderImpl<'a, T>,
>  }
>  
> -#[cfg(feature = "futures-io")]
> -impl<'a, T: futures::io::AsyncWrite + 'a> Encoder<'a, FuturesWriter<T>> {
> -    /// Encode a `pxar` archive into a `futures::io::AsyncWrite` output.
> -    #[inline]
> -    pub async fn from_futures(
> -        output: T,
> -        metadata: &Metadata,
> -    ) -> io::Result<Encoder<'a, FuturesWriter<T>>> {
> -        Encoder::new(FuturesWriter::new(output), metadata).await
> -    }
> -}
> -
>  #[cfg(feature = "tokio-io")]
>  impl<'a, T: tokio::io::AsyncWrite + 'a> Encoder<'a, TokioWriter<T>> {
>      /// Encode a `pxar` archive into a `tokio::io::AsyncWrite` output.
> @@ -214,21 +197,6 @@ impl<'a> File<'a> {
>      }
>  }
>  
> -#[cfg(feature = "futures-io")]
> -impl<'a> futures::io::AsyncWrite for File<'a> {
> -    fn poll_write(self: Pin<&mut Self>, cx: &mut Context, data: &[u8]) -> Poll<io::Result<usize>> {
> -        unsafe { self.map_unchecked_mut(|this| &mut this.inner) }.poll_write(cx, data)
> -    }
> -
> -    fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
> -        unsafe { self.map_unchecked_mut(|this| &mut this.inner) }.poll_flush(cx)
> -    }
> -
> -    fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
> -        unsafe { self.map_unchecked_mut(|this| &mut this.inner) }.poll_close(cx)
> -    }
> -}
> -
>  #[cfg(feature = "tokio-io")]
>  impl<'a> tokio::io::AsyncWrite for File<'a> {
>      fn poll_write(self: Pin<&mut Self>, cx: &mut Context, data: &[u8]) -> Poll<io::Result<usize>> {
> @@ -244,55 +212,6 @@ impl<'a> tokio::io::AsyncWrite for File<'a> {
>      }
>  }
>  
> -/// Pxar encoder write adapter for `futures::io::AsyncWrite`.
> -#[cfg(feature = "futures-io")]
> -mod futures_writer {
> -    use std::io;
> -    use std::pin::Pin;
> -    use std::task::{Context, Poll};
> -
> -    use crate::encoder::SeqWrite;
> -
> -    pub struct FuturesWriter<T> {
> -        inner: Option<T>,
> -    }
> -
> -    impl<T: futures::io::AsyncWrite> FuturesWriter<T> {
> -        pub fn new(inner: T) -> Self {
> -            Self { inner: Some(inner) }
> -        }
> -
> -        fn inner_mut(&mut self) -> io::Result<Pin<&mut T>> {
> -            let inner = self
> -                .inner
> -                .as_mut()
> -                .ok_or_else(|| io_format_err!("write after close"))?;
> -            Ok(unsafe { Pin::new_unchecked(inner) })
> -        }
> -
> -        fn inner(self: Pin<&mut Self>) -> io::Result<Pin<&mut T>> {
> -            unsafe { self.get_unchecked_mut() }.inner_mut()
> -        }
> -    }
> -
> -    impl<T: futures::io::AsyncWrite> SeqWrite for FuturesWriter<T> {
> -        fn poll_seq_write(
> -            self: Pin<&mut Self>,
> -            cx: &mut Context,
> -            buf: &[u8],
> -        ) -> Poll<io::Result<usize>> {
> -            let this = unsafe { self.get_unchecked_mut() };
> -            this.inner_mut()?.poll_write(cx, buf)
> -        }
> -
> -        fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
> -            self.inner()?.poll_flush(cx)
> -        }
> -    }
> -}
> -
> -pub use futures_writer::FuturesWriter;
> -
>  /// Pxar encoder write adapter for `tokio::io::AsyncWrite`.
>  #[cfg(feature = "tokio-io")]
>  mod tokio_writer {
> diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs
> index f186aa8..fdd04ae 100644
> --- a/src/encoder/mod.rs
> +++ b/src/encoder/mod.rs
> @@ -818,7 +818,7 @@ impl<'a> FileImpl<'a> {
>      }
>  
>      /// Poll write interface to more easily connect to tokio/futures.
> -    #[cfg(any(feature = "tokio-io", feature = "futures-io"))]
> +    #[cfg(feature = "tokio-io")]
>      pub fn poll_write(
>          self: Pin<&mut Self>,
>          cx: &mut Context,
> @@ -838,7 +838,7 @@ impl<'a> FileImpl<'a> {
>      }
>  
>      /// Poll flush interface to more easily connect to tokio/futures.
> -    #[cfg(any(feature = "tokio-io", feature = "futures-io"))]
> +    #[cfg(feature = "tokio-io")]
>      pub fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
>          unsafe {
>              self.map_unchecked_mut(|this| &mut this.output)
> @@ -850,7 +850,7 @@ impl<'a> FileImpl<'a> {
>      ///
>      /// This just calls flush, though, since we're just a virtual writer writing to the file
>      /// provided by our encoder.
> -    #[cfg(any(feature = "tokio-io", feature = "futures-io"))]
> +    #[cfg(feature = "tokio-io")]
>      pub fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
>          unsafe {
>              self.map_unchecked_mut(|this| &mut this.output)
> @@ -897,18 +897,3 @@ impl<'a> tokio::io::AsyncWrite for FileImpl<'a> {
>          FileImpl::poll_close(self, cx)
>      }
>  }
> -
> -#[cfg(feature = "futures-io")]
> -impl<'a> futures::io::AsyncWrite for FileImpl<'a> {
> -    fn poll_write(self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll<io::Result<usize>> {
> -        FileImpl::poll_write(self, cx, buf)
> -    }
> -
> -    fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
> -        FileImpl::poll_flush(self, cx)
> -    }
> -
> -    fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
> -        FileImpl::poll_close(self, cx)
> -    }
> -}
> -- 
> 2.20.1
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends
  2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
                   ` (19 preceding siblings ...)
  2021-01-12 13:58 ` [pbs-devel] [RFC pxar 3/3] remove futures-io feature Fabian Grünbichler
@ 2021-01-12 14:52 ` Wolfgang Bumiller
  2021-01-14 13:39   ` [pbs-devel] [PATCH proxmox 1/3] fix u2f example Fabian Grünbichler
  2021-01-14 13:41   ` [pbs-devel] [PATCH pxar 1/2] fix example Fabian Grünbichler
  20 siblings, 2 replies; 29+ messages in thread
From: Wolfgang Bumiller @ 2021-01-12 14:52 UTC (permalink / raw)
  To: Fabian Grünbichler; +Cc: pbs-devel

Apart from the stream issue in the pxar patches, this series looks good
to me. Surprisingly few changes actually.

On Tue, Jan 12, 2021 at 02:58:10PM +0100, Fabian Grünbichler wrote:
> this series updates to tokio 1.0 and related crates:
> - bytes 1
> - openssl 0.10
> - tokio-openssl 0.6.1
> - hyper 0.14
> - h2 0.3
> - tokio-stream (new, split out)
> - tokio-util 0.6
> - rustyline 7
> - pin-project 1
> - nix 0.19.1
> - crossbeam-channel 0.5
> 
> the main changes are:
> - mio no longer exposed by tokio, PollEvented is replaced by AsyncFd
> - tokio runtime setup / interface was adapted
> - tokio Stream code got split into a separate crate until std::stream exists
> - tokio::io::AsyncRead using ReadBuf
> - tokio::time::{Sleep,Timeout} no longer Unpin and renamed (delay -> sleep)
> - tokio-openssl API changed
> - hyper HTTP2 upgrade API changed
> 
> the recently introduced TimeoutFutureExt from the proxmox crate is dropped in
> favour of using tokio::time::timeout directly, since it only had three call
> sites.
> 
> the unused futures-io feature (and related code) in pxar was dropped.
> 
> all the important Stream wrappers/adapters now exist in tokio-stream.
> 
> AFAICT no performance regression or otherwise (anymore)
> 
> proxmox:
>  proxmox/Cargo.toml              | 13 +++++----
>  proxmox/debian/control          | 61 +++++++++++++++++++++++++++--------------
>  proxmox/src/api/cli/readline.rs |  4 ++-
>  proxmox/src/tools/future.rs     | 48 --------------------------------
>  proxmox/src/tools/mod.rs        |  1 -
>  proxmox/src/tools/websocket.rs  | 18 ++++++------
>  6 files changed, 59 insertions(+), 86 deletions(-)
> 
> proxmox-backup:
>  Cargo.toml                             | 25 +++++++------
>  debian/control                         | 49 ++++++++++++-------------
>  examples/h2client.rs                   | 37 ++++++++++---------
>  examples/h2s-client.rs                 | 67 ++++++++++++++++------------------
>  examples/h2s-server.rs                 | 42 ++++++++++-----------
>  examples/h2server.rs                   | 56 +++++++++++++++-------------
>  src/api2/admin/datastore.rs            |  3 +-
>  src/api2/backup.rs                     |  5 +--
>  src/api2/node.rs                       | 14 +++----
>  src/api2/reader.rs                     |  5 +--
>  src/backup/async_index_reader.rs       | 23 ++++++------
>  src/bin/proxmox-backup-client.rs       |  5 ++-
>  src/bin/proxmox-backup-manager.rs      |  2 +-
>  src/bin/proxmox-backup-proxy.rs        | 38 ++++++++++++++-----
>  src/bin/proxmox-daily-update.rs        |  2 +-
>  src/bin/proxmox-tape.rs                |  2 +-
>  src/bin/proxmox_backup_client/mount.rs |  5 ++-
>  src/client/backup_writer.rs            | 10 ++---
>  src/client/http_client.rs              | 40 +++++++++++---------
>  src/server/command_socket.rs           |  2 +-
>  src/server/rest.rs                     | 12 +++---
>  src/tools/async_channel_writer.rs      |  2 +-
>  src/tools/async_io.rs                  | 52 ++------------------------
>  src/tools/broadcast_future.rs          |  2 +-
>  src/tools/daemon.rs                    |  8 ++--
>  src/tools/http.rs                      | 11 +++---
>  src/tools/runtime.rs                   |  6 +--
>  src/tools/wrapped_reader_stream.rs     |  8 ++--
>  src/tools/zip.rs                       |  1 -
>  tests/worker-task-abort.rs             |  2 +-
>  30 files changed, 255 insertions(+), 281 deletions(-)
> 
> proxmox-backup-qemu:
>  Cargo.toml     | 14 ++++++++------
>  src/backup.rs  |  9 ++++-----
>  src/restore.rs |  9 ++++-----
>  3 files changed, 16 insertions(+), 16 deletions(-)
> 
> proxmox-fuse:
>  Cargo.toml     |  7 +++++--
>  debian/control | 22 ++++++++++------------
>  src/fuse_fd.rs | 30 ------------------------------
>  src/session.rs | 14 ++++++--------
>  4 files changed, 21 insertions(+), 52 deletions(-)
> 
> pxar:
>  Cargo.toml          |  11 ++---
>  debian/control      |  78 +++++++++--------------------
>  src/accessor/aio.rs |  41 ++++------------
>  src/decoder/aio.rs  | 139 ++++++++--------------------------------------------
>  src/encoder/aio.rs  |  81 ------------------------------
>  src/encoder/mod.rs  |  21 ++------
>  src/lib.rs          |  25 ++--------
>  src/util.rs         |   7 +--
>  8 files changed, 67 insertions(+), 336 deletions(-)
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 




^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox 1/3] fix u2f example
  2021-01-12 14:52 ` [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Wolfgang Bumiller
@ 2021-01-14 13:39   ` Fabian Grünbichler
  2021-01-14 13:39     ` [pbs-devel] [PATCH proxmox-backup] proxmox XXX: adapt to moved ParameterSchema Fabian Grünbichler
                       ` (2 more replies)
  2021-01-14 13:41   ` [pbs-devel] [PATCH pxar 1/2] fix example Fabian Grünbichler
  1 sibling, 3 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-14 13:39 UTC (permalink / raw)
  To: pbs-devel; +Cc: Wolfgang Bumiller

From: Wolfgang Bumiller <w.bumiller@proxmox.com>

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
 proxmox/examples/u2ftest.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/proxmox/examples/u2ftest.rs b/proxmox/examples/u2ftest.rs
index fc5ada3..ad09ed5 100644
--- a/proxmox/examples/u2ftest.rs
+++ b/proxmox/examples/u2ftest.rs
@@ -52,7 +52,7 @@ use hyper::service::{make_service_fn, service_fn};
 use hyper::{Body, Request, Response, Server};
 use serde::{Deserialize, Serialize};
 use serde_json::Value;
-use tokio::stream::StreamExt;
+use futures::stream::TryStreamExt;
 
 use proxmox::tools::tfa::u2f;
 
@@ -65,7 +65,7 @@ fn main() {
 }
 
 #[cfg(feature = "examples")]
-#[tokio::main]
+#[tokio::main(flavor = "current_thread")]
 async fn main() -> Result<(), Error> {
     do_main().await
 }
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox-backup] proxmox XXX: adapt to moved ParameterSchema
  2021-01-14 13:39   ` [pbs-devel] [PATCH proxmox 1/3] fix u2f example Fabian Grünbichler
@ 2021-01-14 13:39     ` Fabian Grünbichler
  2021-01-14 13:39     ` [pbs-devel] [PATCH proxmox 2/3] move ParameterSchema from router to schema Fabian Grünbichler
  2021-01-14 13:39     ` [pbs-devel] [PATCH proxmox 3/3] build: add autopkgtest target Fabian Grünbichler
  2 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-14 13:39 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---

Notes:
    requires corresponding patch in proxmox + versioned dep bump + commit title update

 src/server/rest.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/server/rest.rs b/src/server/rest.rs
index c30d1c92..79c9c3d0 100644
--- a/src/server/rest.rs
+++ b/src/server/rest.rs
@@ -26,7 +26,6 @@ use proxmox::api::{
     ApiHandler,
     ApiMethod,
     HttpError,
-    ParameterSchema,
     Permission,
     RpcEnvironment,
     RpcEnvironmentType,
@@ -34,6 +33,7 @@ use proxmox::api::{
 };
 use proxmox::api::schema::{
     ObjectSchemaType,
+    ParameterSchema,
     parse_parameter_strings,
     parse_simple_value,
     verify_json_object,
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox 2/3] move ParameterSchema from router to schema
  2021-01-14 13:39   ` [pbs-devel] [PATCH proxmox 1/3] fix u2f example Fabian Grünbichler
  2021-01-14 13:39     ` [pbs-devel] [PATCH proxmox-backup] proxmox XXX: adapt to moved ParameterSchema Fabian Grünbichler
@ 2021-01-14 13:39     ` Fabian Grünbichler
  2021-01-14 13:39     ` [pbs-devel] [PATCH proxmox 3/3] build: add autopkgtest target Fabian Grünbichler
  2 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-14 13:39 UTC (permalink / raw)
  To: pbs-devel

it's the place where it belongs, and unbreaks the --no-default-features
build

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---

Notes:
    breaking change, requires corresponding patch in proxmox-backup

 proxmox-api-macro/Cargo.toml        |  2 +-
 proxmox-api-macro/src/api/method.rs |  4 +--
 proxmox-api-macro/tests/allof.rs    |  4 +--
 proxmox/src/api/cli/completion.rs   |  1 -
 proxmox/src/api/cli/getopts.rs      |  1 -
 proxmox/src/api/mod.rs              |  3 +-
 proxmox/src/api/router.rs           | 55 +----------------------------
 proxmox/src/api/schema.rs           | 54 +++++++++++++++++++++++++++-
 8 files changed, 60 insertions(+), 64 deletions(-)

diff --git a/proxmox-api-macro/Cargo.toml b/proxmox-api-macro/Cargo.toml
index ab6c590..fb2e842 100644
--- a/proxmox-api-macro/Cargo.toml
+++ b/proxmox-api-macro/Cargo.toml
@@ -19,7 +19,7 @@ syn = { version = "1.0", features = [ "full", "visit-mut" ] }
 
 [dev-dependencies]
 futures = "0.3"
-proxmox = { path = "../proxmox", features = [ "test-harness" ] }
+proxmox = { version = "0.9.1", path = "../proxmox", features = [ "test-harness" ] }
 serde = "1.0"
 serde_derive = "1.0"
 serde_json = "1.0"
diff --git a/proxmox-api-macro/src/api/method.rs b/proxmox-api-macro/src/api/method.rs
index 23501bc..a03e654 100644
--- a/proxmox-api-macro/src/api/method.rs
+++ b/proxmox-api-macro/src/api/method.rs
@@ -677,7 +677,7 @@ fn serialize_input_schema(
                 pub const #input_schema_name: ::proxmox::api::schema::ObjectSchema = #ts;
             },
             quote_spanned! { func_sig_span =>
-                ::proxmox::api::router::ParameterSchema::Object(&#input_schema_name)
+                ::proxmox::api::schema::ParameterSchema::Object(&#input_schema_name)
             },
         ));
     }
@@ -750,7 +750,7 @@ fn serialize_input_schema(
                 );
         },
         quote_spanned! { func_sig_span =>
-            ::proxmox::api::router::ParameterSchema::AllOf(&#input_schema_name)
+            ::proxmox::api::schema::ParameterSchema::AllOf(&#input_schema_name)
         },
     ))
 }
diff --git a/proxmox-api-macro/tests/allof.rs b/proxmox-api-macro/tests/allof.rs
index 1c1b9a9..9fcf979 100644
--- a/proxmox-api-macro/tests/allof.rs
+++ b/proxmox-api-macro/tests/allof.rs
@@ -136,7 +136,7 @@ pub fn hello(it: IndexText, nv: NameValue) -> Result<(NameValue, IndexText), Err
 fn hello_schema_check() {
     const TEST_METHOD: ::proxmox::api::ApiMethod = ::proxmox::api::ApiMethod::new_full(
         &::proxmox::api::ApiHandler::Sync(&api_function_hello),
-        ::proxmox::api::router::ParameterSchema::AllOf(&::proxmox::api::schema::AllOfSchema::new(
+        ::proxmox::api::schema::ParameterSchema::AllOf(&::proxmox::api::schema::AllOfSchema::new(
             "Hello method.",
             &[&IndexText::API_SCHEMA, &NameValue::API_SCHEMA],
         )),
@@ -176,7 +176,7 @@ fn with_extra_schema_check() {
 
     const TEST_METHOD: ::proxmox::api::ApiMethod = ::proxmox::api::ApiMethod::new_full(
         &::proxmox::api::ApiHandler::Sync(&api_function_with_extra),
-        ::proxmox::api::router::ParameterSchema::AllOf(&::proxmox::api::schema::AllOfSchema::new(
+        ::proxmox::api::schema::ParameterSchema::AllOf(&::proxmox::api::schema::AllOfSchema::new(
             "Extra method.",
             &[
                 &INNER_SCHEMA,
diff --git a/proxmox/src/api/cli/completion.rs b/proxmox/src/api/cli/completion.rs
index 42b3915..a660473 100644
--- a/proxmox/src/api/cli/completion.rs
+++ b/proxmox/src/api/cli/completion.rs
@@ -1,6 +1,5 @@
 use super::*;
 
-use crate::api::router::ParameterSchema;
 use crate::api::schema::*;
 
 fn record_done_argument(
diff --git a/proxmox/src/api/cli/getopts.rs b/proxmox/src/api/cli/getopts.rs
index adf0658..6248fe5 100644
--- a/proxmox/src/api/cli/getopts.rs
+++ b/proxmox/src/api/cli/getopts.rs
@@ -3,7 +3,6 @@ use std::collections::HashMap;
 use anyhow::*;
 use serde_json::Value;
 
-use crate::api::router::ParameterSchema;
 use crate::api::schema::*;
 
 #[derive(Debug)]
diff --git a/proxmox/src/api/mod.rs b/proxmox/src/api/mod.rs
index 5319cc1..8c6f597 100644
--- a/proxmox/src/api/mod.rs
+++ b/proxmox/src/api/mod.rs
@@ -43,8 +43,7 @@ pub mod router;
 #[cfg(feature = "router")]
 #[doc(inline)]
 pub use router::{
-    ApiFuture, ApiHandler, ApiMethod, ApiResponseFuture, ParameterSchema, Router, SubRoute,
-    SubdirMap,
+    ApiFuture, ApiHandler, ApiMethod, ApiResponseFuture, Router, SubRoute, SubdirMap,
 };
 
 #[cfg(feature = "cli")]
diff --git a/proxmox/src/api/router.rs b/proxmox/src/api/router.rs
index 2f4b6c4..609a89e 100644
--- a/proxmox/src/api/router.rs
+++ b/proxmox/src/api/router.rs
@@ -10,7 +10,7 @@ use hyper::Body;
 use percent_encoding::percent_decode_str;
 use serde_json::Value;
 
-use crate::api::schema::{self, AllOfSchema, ObjectSchema, Schema};
+use crate::api::schema::{self, ObjectSchema, ParameterSchema, Schema};
 use crate::api::RpcEnvironment;
 
 use super::Permission;
@@ -430,59 +430,6 @@ impl ReturnType {
     }
 }
 
-/// Parameters are objects, but we have two types of object schemas, the regular one and the
-/// `AllOf` schema.
-#[derive(Clone, Copy, Debug)]
-#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
-pub enum ParameterSchema {
-    Object(&'static ObjectSchema),
-    AllOf(&'static AllOfSchema),
-}
-
-impl schema::ObjectSchemaType for ParameterSchema {
-    type PropertyIter = Box<dyn Iterator<Item = &'static schema::SchemaPropertyEntry>>;
-
-    fn description(&self) -> &'static str {
-        match self {
-            ParameterSchema::Object(o) => o.description(),
-            ParameterSchema::AllOf(o) => o.description(),
-        }
-    }
-
-    fn lookup(&self, key: &str) -> Option<(bool, &Schema)> {
-        match self {
-            ParameterSchema::Object(o) => o.lookup(key),
-            ParameterSchema::AllOf(o) => o.lookup(key),
-        }
-    }
-
-    fn properties(&self) -> Self::PropertyIter {
-        match self {
-            ParameterSchema::Object(o) => Box::new(o.properties()),
-            ParameterSchema::AllOf(o) => Box::new(o.properties()),
-        }
-    }
-
-    fn additional_properties(&self) -> bool {
-        match self {
-            ParameterSchema::Object(o) => o.additional_properties(),
-            ParameterSchema::AllOf(o) => o.additional_properties(),
-        }
-    }
-}
-
-impl From<&'static ObjectSchema> for ParameterSchema {
-    fn from(schema: &'static ObjectSchema) -> Self {
-        ParameterSchema::Object(schema)
-    }
-}
-
-impl From<&'static AllOfSchema> for ParameterSchema {
-    fn from(schema: &'static AllOfSchema) -> Self {
-        ParameterSchema::AllOf(schema)
-    }
-}
-
 /// This struct defines a synchronous API call which returns the result as json `Value`
 #[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
 pub struct ApiMethod {
diff --git a/proxmox/src/api/schema.rs b/proxmox/src/api/schema.rs
index 1378d78..c2cc61e 100644
--- a/proxmox/src/api/schema.rs
+++ b/proxmox/src/api/schema.rs
@@ -10,7 +10,6 @@ use anyhow::{bail, format_err, Error};
 use serde_json::{json, Value};
 use url::form_urlencoded;
 
-use super::router::ParameterSchema;
 use crate::api::const_regex::ConstRegexPattern;
 
 /// Error type for schema validation
@@ -752,6 +751,59 @@ impl PartialEq for ApiStringFormat {
     }
 }
 
+/// Parameters are objects, but we have two types of object schemas, the regular one and the
+/// `AllOf` schema.
+#[derive(Clone, Copy, Debug)]
+#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
+pub enum ParameterSchema {
+    Object(&'static ObjectSchema),
+    AllOf(&'static AllOfSchema),
+}
+
+impl ObjectSchemaType for ParameterSchema {
+    type PropertyIter = Box<dyn Iterator<Item = &'static SchemaPropertyEntry>>;
+
+    fn description(&self) -> &'static str {
+        match self {
+            ParameterSchema::Object(o) => o.description(),
+            ParameterSchema::AllOf(o) => o.description(),
+        }
+    }
+
+    fn lookup(&self, key: &str) -> Option<(bool, &Schema)> {
+        match self {
+            ParameterSchema::Object(o) => o.lookup(key),
+            ParameterSchema::AllOf(o) => o.lookup(key),
+        }
+    }
+
+    fn properties(&self) -> Self::PropertyIter {
+        match self {
+            ParameterSchema::Object(o) => Box::new(o.properties()),
+            ParameterSchema::AllOf(o) => Box::new(o.properties()),
+        }
+    }
+
+    fn additional_properties(&self) -> bool {
+        match self {
+            ParameterSchema::Object(o) => o.additional_properties(),
+            ParameterSchema::AllOf(o) => o.additional_properties(),
+        }
+    }
+}
+
+impl From<&'static ObjectSchema> for ParameterSchema {
+    fn from(schema: &'static ObjectSchema) -> Self {
+        ParameterSchema::Object(schema)
+    }
+}
+
+impl From<&'static AllOfSchema> for ParameterSchema {
+    fn from(schema: &'static AllOfSchema) -> Self {
+        ParameterSchema::AllOf(schema)
+    }
+}
+
 /// Helper function to parse boolean values
 ///
 /// - true:  `1 | on | yes | true`
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH proxmox 3/3] build: add autopkgtest target
  2021-01-14 13:39   ` [pbs-devel] [PATCH proxmox 1/3] fix u2f example Fabian Grünbichler
  2021-01-14 13:39     ` [pbs-devel] [PATCH proxmox-backup] proxmox XXX: adapt to moved ParameterSchema Fabian Grünbichler
  2021-01-14 13:39     ` [pbs-devel] [PATCH proxmox 2/3] move ParameterSchema from router to schema Fabian Grünbichler
@ 2021-01-14 13:39     ` Fabian Grünbichler
  2 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-14 13:39 UTC (permalink / raw)
  To: pbs-devel

which runs the autopkgtests on the built packages.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---

Notes:
    they take a while, but test all the features individually + those only required by examples

 Makefile | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 963c507..b0ab80a 100644
--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,9 @@ deb: $(foreach c,$(CRATES), $c-deb)
 	echo $(foreach c,$(CRATES), $c-deb)
 	lintian build/*.deb
 
+.PHONY: autopkgtest
+autopkgtest: $(foreach c,$(CRATES), $c-autopkgtest)
+
 .PHONY: dinstall
 dinstall:
 	$(MAKE) clean
@@ -21,6 +24,10 @@ dinstall:
 	./build.sh $*
 	touch $@
 
+%-autopkgtest:
+	autopkgtest build/$* build/*.deb -- null
+	touch $@
+
 .PHONY: check
 check:
 	cargo test
@@ -44,7 +51,7 @@ doc:
 .PHONY: clean
 clean:
 	cargo clean
-	rm -rf build *-deb
+	rm -rf build *-deb *-autopkgtest
 
 .PHONY: update
 update:
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH pxar 1/2] fix example
  2021-01-12 14:52 ` [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Wolfgang Bumiller
  2021-01-14 13:39   ` [pbs-devel] [PATCH proxmox 1/3] fix u2f example Fabian Grünbichler
@ 2021-01-14 13:41   ` Fabian Grünbichler
  2021-01-14 13:41     ` [pbs-devel] [PATCH pxar 2/2] build: fix --no-default-features Fabian Grünbichler
  1 sibling, 1 reply; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-14 13:41 UTC (permalink / raw)
  To: pbs-devel; +Cc: Wolfgang Bumiller

From: Wolfgang Bumiller <w.bumiller@proxmox.com>

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
 examples/apxar.rs | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/examples/apxar.rs b/examples/apxar.rs
index 03c7590..0c62242 100644
--- a/examples/apxar.rs
+++ b/examples/apxar.rs
@@ -12,21 +12,8 @@ async fn main() {
     let mut reader = Decoder::from_tokio(file)
         .await
         .expect("failed to open pxar archive contents");
-    let mut i = 0;
-    while let Some(entry) = reader.next().await {
-        println!("{:#?}", entry.expect("failed to parse entry").path());
-        i += 1;
-        if i == 2 {
-            break;
-        }
-    }
 
-    // Use a Stream for the remaining entries:
-    use futures::stream::StreamExt;
-
-    let mut stream = reader.into_stream();
-
-    while let Some(entry) = stream.next().await {
+    while let Some(entry) = reader.next().await {
         println!("{:#?}", entry.expect("failed to parse entry").path());
     }
 }
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

* [pbs-devel] [PATCH pxar 2/2] build: fix --no-default-features
  2021-01-14 13:41   ` [pbs-devel] [PATCH pxar 1/2] fix example Fabian Grünbichler
@ 2021-01-14 13:41     ` Fabian Grünbichler
  0 siblings, 0 replies; 29+ messages in thread
From: Fabian Grünbichler @ 2021-01-14 13:41 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/encoder/aio.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/encoder/aio.rs b/src/encoder/aio.rs
index 908e019..609bd0f 100644
--- a/src/encoder/aio.rs
+++ b/src/encoder/aio.rs
@@ -259,4 +259,5 @@ mod tokio_writer {
     }
 }
 
+#[cfg(feature = "tokio-io")]
 pub use tokio_writer::TokioWriter;
-- 
2.20.1





^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2021-01-14 13:42 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 1/4] Cargo.toml: update to tokio 1.0 Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 2/4] update to rustyline 7 Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 3/4] update to tokio 1.0 Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 4/4] tokio 1.0: drop TimeoutFutureExt Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 01/12] update to tokio 1.0 Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 02/12] tokio 1.0: delay -> sleep Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 03/12] proxmox XXX: use tokio::time::timeout directly Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 04/12] tokio 1.0: AsyncRead/Seek with ReadBuf Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 05/12] tokio: adapt to 1.0 runtime changes Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 06/12] tokio: adapt to 1.0 process:Child changes Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 07/12] tokio 1.0: use ReceiverStream from tokio-stream Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 08/12] tokio 1.0: update to new tokio-openssl interface Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 09/12] tokio 1.0: update to new Signal interface Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 10/12] hyper: use new hyper::upgrade Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 11/12] examples: unify h2 examples Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 12/12] cleanup: remove unnecessary 'mut' and '.clone()' Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-fuse] update to tokio 1.0 Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH pxar 1/3] " Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [RFC pxar 2/3] clippy: use matches! instead of match Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [RFC pxar 3/3] remove futures-io feature Fabian Grünbichler
2021-01-12 14:42   ` Wolfgang Bumiller
2021-01-12 14:52 ` [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Wolfgang Bumiller
2021-01-14 13:39   ` [pbs-devel] [PATCH proxmox 1/3] fix u2f example Fabian Grünbichler
2021-01-14 13:39     ` [pbs-devel] [PATCH proxmox-backup] proxmox XXX: adapt to moved ParameterSchema Fabian Grünbichler
2021-01-14 13:39     ` [pbs-devel] [PATCH proxmox 2/3] move ParameterSchema from router to schema Fabian Grünbichler
2021-01-14 13:39     ` [pbs-devel] [PATCH proxmox 3/3] build: add autopkgtest target Fabian Grünbichler
2021-01-14 13:41   ` [pbs-devel] [PATCH pxar 1/2] fix example Fabian Grünbichler
2021-01-14 13:41     ` [pbs-devel] [PATCH pxar 2/2] build: fix --no-default-features Fabian Grünbichler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal