From d8d0d039aa826a9020b74c7154c1ddd2b8e191d2 Mon Sep 17 00:00:00 2001 From: jD91mZM2 Date: Tue, 16 Mar 2021 15:28:21 +0100 Subject: [PATCH] Update tokio --- Cargo.lock | 169 +++++++---------------------- xidlehook-core/Cargo.toml | 2 +- xidlehook-core/src/lib.rs | 5 +- xidlehook-daemon/Cargo.toml | 2 +- xidlehook-daemon/src/main.rs | 8 +- xidlehook-daemon/src/socket/mod.rs | 7 +- 6 files changed, 48 insertions(+), 145 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca5ebbc..92c15e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,7 +15,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -76,7 +76,7 @@ dependencies = [ "polling", "vec-arena", "waker-fn", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -118,7 +118,7 @@ dependencies = [ "memchr", "num_cpus", "once_cell", - "pin-project-lite 0.2.5", + "pin-project-lite", "pin-utils", "slab", "wasm-bindgen-futures", @@ -144,7 +144,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ "hermit-abi", "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -181,9 +181,9 @@ checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" [[package]] name = "bytes" -version = "0.5.6" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" [[package]] name = "cache-padded" @@ -282,28 +282,6 @@ dependencies = [ "instant", ] -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - [[package]] name = "futures" version = "0.3.13" @@ -363,7 +341,7 @@ dependencies = [ "futures-io", "memchr", "parking", - "pin-project-lite 0.2.5", + "pin-project-lite", "waker-fn", ] @@ -404,7 +382,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.5", + "pin-project-lite", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -460,15 +438,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - [[package]] name = "itoa" version = "0.4.7" @@ -484,16 +453,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - [[package]] name = "kv-log-macro" version = "1.0.7" @@ -526,7 +485,7 @@ dependencies = [ "libpulse-sys", "num-derive", "num-traits", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -539,7 +498,7 @@ dependencies = [ "num-derive", "num-traits", "pkg-config", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -560,44 +519,25 @@ checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "mio" -version = "0.6.23" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +checksum = "2182a122f3b7f3f5329cb1972cee089ba2459a0a80a56935e6e674f096f8d839" dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", "libc", "log", "miow", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio", + "ntapi", + "winapi", ] [[package]] name = "miow" -version = "0.2.2" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" +checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", + "socket2", + "winapi", ] [[package]] @@ -610,17 +550,6 @@ dependencies = [ "socket2", ] -[[package]] -name = "net2" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.9", -] - [[package]] name = "nix" version = "0.15.0" @@ -634,6 +563,15 @@ dependencies = [ "void", ] +[[package]] +name = "ntapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +dependencies = [ + "winapi", +] + [[package]] name = "num-derive" version = "0.3.3" @@ -676,12 +614,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" -[[package]] -name = "pin-project-lite" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" - [[package]] name = "pin-project-lite" version = "0.2.5" @@ -710,7 +642,7 @@ dependencies = [ "libc", "log", "wepoll-sys", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -851,7 +783,7 @@ checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" dependencies = [ "cfg-if 1.0.0", "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -924,30 +856,27 @@ dependencies = [ [[package]] name = "tokio" -version = "0.2.25" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" +checksum = "8d56477f6ed99e10225f38f9f75f872f29b8b8bd8c0b946f63345bb144e9eeda" dependencies = [ + "autocfg", "bytes", - "fnv", - "futures-core", - "lazy_static", "libc", "memchr", "mio", - "mio-uds", - "pin-project-lite 0.1.12", + "once_cell", + "pin-project-lite", "signal-hook-registry", - "slab", "tokio-macros", - "winapi 0.3.9", + "winapi", ] [[package]] name = "tokio-macros" -version = "0.2.6" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" +checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57" dependencies = [ "proc-macro2", "quote", @@ -1096,12 +1025,6 @@ dependencies = [ "cc", ] -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - [[package]] name = "winapi" version = "0.3.9" @@ -1112,12 +1035,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -1130,7 +1047,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1139,16 +1056,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - [[package]] name = "x11" version = "2.18.2" diff --git a/xidlehook-core/Cargo.toml b/xidlehook-core/Cargo.toml index a89a5a3..bdac78f 100644 --- a/xidlehook-core/Cargo.toml +++ b/xidlehook-core/Cargo.toml @@ -17,7 +17,7 @@ log = "0.4.8" nix = "0.15.0" structopt = "0.3.5" xcb = { version = "0.9.0", features = ["x11", "screensaver"] } -tokio = { version = "0.2.21", optional = true, features = ["time", "stream"] } +tokio = { version = "1.3.0", optional = true, features = ["time"] } [dependencies.libpulse-binding] optional = true diff --git a/xidlehook-core/src/lib.rs b/xidlehook-core/src/lib.rs index f66260f..7292190 100644 --- a/xidlehook-core/src/lib.rs +++ b/xidlehook-core/src/lib.rs @@ -532,7 +532,7 @@ where async_std::task::sleep(delay).await; #[cfg(feature = "tokio")] if cfg!(not(feature = "async-std")) { - tokio::time::delay_for(delay).await; + tokio::time::sleep(delay).await; } if let Some(time_difference) = sleep_start.elapsed().checked_sub(delay) { @@ -552,8 +552,7 @@ where async_std::future::pending::<()>().await; #[cfg(feature = "tokio")] if cfg!(not(feature = "async-std")) { - use tokio::stream::StreamExt; - tokio::stream::pending::<()>().next().await; + std::future::pending::<()>().await; } }, Action::Quit => break, diff --git a/xidlehook-daemon/Cargo.toml b/xidlehook-daemon/Cargo.toml index ea194e6..03f5468 100644 --- a/xidlehook-daemon/Cargo.toml +++ b/xidlehook-daemon/Cargo.toml @@ -22,7 +22,7 @@ serde_json = "1.0.42" structopt = "0.3.5" xcb = { version = "0.9.0", features = ["x11", "screensaver"] } xidlehook-core = { version = "0.3.0", default-features = false, features = ["tokio"] } -tokio = { version = "0.2.21", features = ["io-util", "macros", "rt-core", "signal", "stream", "sync", "uds"] } +tokio = { version = "1.3.0", features = ["io-util", "macros", "signal", "sync", "net", "rt"] } [features] default = ["pulse"] diff --git a/xidlehook-daemon/src/main.rs b/xidlehook-daemon/src/main.rs index 0fd1262..027ed53 100644 --- a/xidlehook-daemon/src/main.rs +++ b/xidlehook-daemon/src/main.rs @@ -20,7 +20,6 @@ use nix::sys::wait; use structopt::StructOpt; use tokio::{ signal::unix::{signal, SignalKind}, - stream::{self, StreamExt}, sync::mpsc, }; use xidlehook_core::{ @@ -81,7 +80,7 @@ pub struct Opt { pub not_when_audio: bool, } -#[tokio::main] +#[tokio::main(flavor = "current_thread")] async fn main() -> xidlehook_core::Result<()> { env_logger::init(); @@ -98,7 +97,7 @@ async fn main() -> xidlehook_core::Result<()> { let mut timers = Vec::new(); let mut iter = opt.timer.iter().peekable(); while iter.peek().is_some() { - // clap-rs will ensure there are always a multiple of 3 + // clap-rs will ensure there are always a multiple of 3 arguments let duration: u64 = match iter.next().unwrap().parse() { Ok(duration) => duration, Err(err) => { @@ -176,8 +175,7 @@ impl App { if let Some(ref mut rx) = socket_rx { rx.recv().await } else { - // TODO: use future::pending() when released - stream::pending::<()>().next().await; + std::future::pending::<()>().await; unreachable!(); } }; diff --git a/xidlehook-daemon/src/socket/mod.rs b/xidlehook-daemon/src/socket/mod.rs index 653c091..3636d3a 100644 --- a/xidlehook-daemon/src/socket/mod.rs +++ b/xidlehook-daemon/src/socket/mod.rs @@ -2,9 +2,8 @@ use std::{convert::Infallible, fs}; use log::{trace, warn}; use tokio::{ - io::{BufReader, BufWriter}, + io::{BufReader, BufWriter, AsyncWriteExt, AsyncBufReadExt}, net::UnixListener, - prelude::*, sync::{mpsc, oneshot}, }; @@ -19,14 +18,14 @@ pub async fn main_loop( ) -> xidlehook_core::Result { let _ = fs::remove_file(address); - let mut listener = UnixListener::bind(address)?; + let listener = UnixListener::bind(address)?; trace!("Bound unix listener on address {:?}", address); loop { let (mut stream, addr) = listener.accept().await?; trace!("Connection from {:?}", addr); - let mut socket_tx = socket_tx.clone(); + let socket_tx = socket_tx.clone(); tokio::spawn(async move { let (reader, writer) = stream.split(); let reader = BufReader::new(reader);