From 9e7701a47ab511d6a82d507db49554d4625cfcda Mon Sep 17 00:00:00 2001 From: Nora Widdecke Date: Wed, 29 Sep 2021 14:35:20 +0200 Subject: store: Update to tokio 1.0. --- Cargo.lock | 18 ++++++++++++++++-- store/Cargo.toml | 5 +++-- store/src/backend/mod.rs | 2 +- store/src/lib.rs | 6 +++--- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b7c9bedd..e04c946d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2969,8 +2969,8 @@ dependencies = [ "sequoia-net", "sequoia-openpgp", "thiserror", - "tokio 0.2.25", - "tokio-util 0.3.1", + "tokio 1.12.0", + "tokio-util 0.6.8", ] [[package]] @@ -3118,6 +3118,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + [[package]] name = "signature" version = "1.3.2" @@ -3546,7 +3555,11 @@ dependencies = [ "libc", "memchr", "mio 0.7.14", + "num_cpus", + "once_cell", + "parking_lot", "pin-project-lite 0.2.7", + "signal-hook-registry", "tokio-macros 1.5.0", "winapi 0.3.9", ] @@ -3606,6 +3619,7 @@ checksum = "08d3725d3efa29485e87311c5b699de63cde14b00ed4d256b8318aa30ca452cd" dependencies = [ "bytes 1.1.0", "futures-core", + "futures-io", "futures-sink", "log", "pin-project-lite 0.2.7", diff --git a/store/Cargo.toml b/store/Cargo.toml index df7076e4..29b40557 100644 --- a/store/Cargo.toml +++ b/store/Cargo.toml @@ -42,8 +42,9 @@ futures-util = "0.3.5" rand = { version = "0.7", default-features = false } rusqlite = "0.24" thiserror = "1.0.2" -tokio = { version = "0.2.19", features = ["rt-core", "tcp", "io-driver", "time"] } -tokio-util = { version = "0.3", features = ["compat"] } +#tokio = { version = "0.2.19", features = ["rt-core", "tcp", "io-driver", "time"] } +tokio = { version = "1", features = ["rt", "full"] } +tokio-util = { version = "0.6", features = ["compat"] } [target.'cfg(target_os="android")'.dependencies.rusqlite] version = "0.24.0" diff --git a/store/src/backend/mod.rs b/store/src/backend/mod.rs index 11f4b193..f3fe648a 100644 --- a/store/src/backend/mod.rs +++ b/store/src/backend/mod.rs @@ -943,7 +943,7 @@ impl KeyServer { let duration = Self::update(&c, net::Policy::Encrypted).await; let duration = duration.unwrap_or_else(|_| min_sleep_time()); - tokio::time::delay_for(random_duration(duration)).await; + tokio::time::sleep(random_duration(duration)).await; } } } diff --git a/store/src/lib.rs b/store/src/lib.rs index 962bce83..df16ecb7 100644 --- a/store/src/lib.rs +++ b/store/src/lib.rs @@ -123,14 +123,14 @@ impl Store { fn connect(c: &Context) -> Result<(RpcRuntime, node::Client)> { let descriptor = descriptor(c); - let rt = tokio::runtime::Builder::new() - .basic_scheduler() + let rt = tokio::runtime::Builder::new_current_thread() .enable_io() .enable_time() .build()?; // Need to enter Tokio context due to Tokio TcpStream creation binding // eagerly to an I/O reactor - let mut rpc_system = rt.enter(|| descriptor.connect())?; + let _guard = rt.enter(); + let mut rpc_system = descriptor.connect()?; let client: node::Client = rpc_system.bootstrap(Side::Server); -- cgit v1.2.3