aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock181
-rw-r--r--Cargo.toml12
-rw-r--r--examples/basalt.rs2
-rw-r--r--src/conn.rs6
-rw-r--r--src/netapp.rs2
-rw-r--r--src/peering/basalt.rs4
-rw-r--r--src/peering/fullmesh.rs2
-rw-r--r--src/proto.rs2
-rw-r--r--src/util.rs6
9 files changed, 62 insertions, 155 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 97ef663..ab23fd4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -91,7 +91,7 @@ dependencies = [
"polling",
"vec-arena",
"waker-fn",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -125,7 +125,7 @@ dependencies = [
"futures-lite",
"once_cell",
"signal-hook",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -151,7 +151,7 @@ dependencies = [
"memchr",
"num_cpus",
"once_cell",
- "pin-project-lite 0.2.6",
+ "pin-project-lite",
"pin-utils",
"slab",
"wasm-bindgen-futures",
@@ -188,7 +188,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -237,15 +237,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytes"
-version = "0.5.6"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
+checksum = "e0dcbc35f504eb6fc275a6d20e4ebcda18cf50d40ba6fabff8c711fa16cb3b16"
[[package]]
name = "bytes"
-version = "0.6.0"
+version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e0dcbc35f504eb6fc275a6d20e4ebcda18cf50d40ba6fabff8c711fa16cb3b16"
+checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
[[package]]
name = "cache-padded"
@@ -281,7 +281,7 @@ dependencies = [
"num-integer",
"num-traits",
"time",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -377,34 +377,12 @@ dependencies = [
]
[[package]]
-name = "fnv"
-version = "1.0.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
-
-[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[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"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -463,7 +441,7 @@ dependencies = [
"futures-io",
"memchr",
"parking",
- "pin-project-lite 0.2.6",
+ "pin-project-lite",
"waker-fn",
]
@@ -504,7 +482,7 @@ dependencies = [
"futures-sink",
"futures-task",
"memchr",
- "pin-project-lite 0.2.6",
+ "pin-project-lite",
"pin-utils",
"proc-macro-hack",
"proc-macro-nested",
@@ -573,15 +551,6 @@ dependencies = [
]
[[package]]
-name = "iovec"
-version = "0.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
-dependencies = [
- "libc",
-]
-
-[[package]]
name = "js-sys"
version = "0.3.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -591,20 +560,9 @@ dependencies = [
]
[[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 = "kuska-handshake"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da372e4a78da14a8381bb7d992f032b20405ecc2e44e677df21c80bd1e3359e8"
+version = "0.2.0"
+source = "git+https://github.com/Alexis211/handshake?branch=tokio1.0#f4fdccd3e85b712462e5170ff43784810ca0a334"
dependencies = [
"async-std",
"futures",
@@ -685,44 +643,24 @@ checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
[[package]]
name = "mio"
-version = "0.6.23"
+version = "0.7.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4"
+checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16"
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.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d"
+checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
dependencies = [
- "kernel32-sys",
- "net2",
- "winapi 0.2.8",
- "ws2_32-sys",
+ "winapi",
]
[[package]]
@@ -736,19 +674,8 @@ dependencies = [
]
[[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 = "netapp"
-version = "0.1.2"
+version = "0.2.0"
dependencies = [
"arc-swap",
"async-std",
@@ -771,6 +698,15 @@ dependencies = [
]
[[package]]
+name = "ntapi"
+version = "0.3.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -813,12 +749,6 @@ 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.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
@@ -845,7 +775,7 @@ dependencies = [
"libc",
"log",
"wepoll-sys",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -912,7 +842,7 @@ dependencies = [
"fuchsia-cprng",
"libc",
"rand_core 0.3.1",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -1028,7 +958,7 @@ checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e"
dependencies = [
"cfg-if 1.0.0",
"libc",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -1133,34 +1063,31 @@ checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [
"libc",
"wasi",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
name = "tokio"
-version = "0.2.25"
+version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092"
+checksum = "c2c2416fdedca8443ae44b4527de1ea633af61d8f7169ffa6e72c5b53d24efcc"
dependencies = [
- "bytes 0.5.6",
- "fnv",
- "iovec",
- "lazy_static",
+ "autocfg",
+ "bytes 1.1.0",
"libc",
"memchr",
"mio",
- "mio-uds",
"num_cpus",
- "pin-project-lite 0.1.12",
- "slab",
+ "pin-project-lite",
"tokio-macros",
+ "winapi",
]
[[package]]
name = "tokio-macros"
-version = "0.2.6"
+version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a"
+checksum = "154794c8f499c2619acd19e839294703e9e32e7630ef5f46ea80d4ef0fbee5eb"
dependencies = [
"proc-macro2",
"quote",
@@ -1305,12 +1232,6 @@ dependencies = [
[[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"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
@@ -1320,12 +1241,6 @@ dependencies = [
]
[[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"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1337,7 +1252,7 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -1345,13 +1260,3 @@ name = "winapi-x86_64-pc-windows-gnu"
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",
-]
diff --git a/Cargo.toml b/Cargo.toml
index 3f093f2..0a808ab 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "netapp"
-version = "0.1.2"
+version = "0.2.0"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license-file = "LICENSE"
@@ -20,16 +20,14 @@ basalt = ["lru", "rand"]
[dependencies]
async-std = { version = "1.5.0", default-features = false }
-tokio = { version = "0.2", default-features = false, features = ["net", "tcp", "rt-core", "rt-threaded", "sync", "time", "macros"] }
+tokio = { version = "1.0", default-features = false, features = ["net", "rt", "rt-multi-thread", "sync", "time", "macros"] }
serde = { version = "1.0", default-features = false, features = ["derive"] }
rmp-serde = "0.14.3"
hex = "0.4.2"
base64 = "0.12.1"
-structopt = { version = "0.3", default-features = false }
rand = { version = "0.5.5", optional = true }
-chrono = "0.4"
log = "0.4.8"
env_logger = "0.8"
@@ -40,7 +38,11 @@ bytes = "0.6.0"
lru = { version = "0.6", optional = true }
sodiumoxide = { version = "0.2.5-0", package = "kuska-sodiumoxide" }
-kuska-handshake = { version = "0.1.2", features = ["default", "tokio_compat"] }
+kuska-handshake = { version = "0.2.0", git = "https://github.com/Alexis211/handshake", branch = "tokio1.0", features = ["default", "tokio_compat"] }
+
+[dev-dependencies]
+structopt = { version = "0.3", default-features = false }
+chrono = "0.4"
[package.metadata.cargo-all-features]
skip_optional_dependencies = true
diff --git a/examples/basalt.rs b/examples/basalt.rs
index 4ea4f71..91f0982 100644
--- a/examples/basalt.rs
+++ b/examples/basalt.rs
@@ -128,7 +128,7 @@ async fn main() {
async fn sampling_loop(netapp: Arc<NetApp>, basalt: Arc<Basalt>) {
loop {
- tokio::time::delay_for(Duration::from_secs(10)).await;
+ tokio::time::sleep(Duration::from_secs(10)).await;
let peers = basalt.sample(10);
for p in peers {
diff --git a/src/conn.rs b/src/conn.rs
index daa0235..6c5f38a 100644
--- a/src/conn.rs
+++ b/src/conn.rs
@@ -102,7 +102,7 @@ impl ServerConn {
}
pub fn close(&self) {
- self.close_send.broadcast(true).unwrap();
+ self.close_send.send(true).unwrap();
}
}
@@ -217,7 +217,7 @@ impl ClientConn {
.log_err("could not write None in query_send");
if self.inflight.lock().unwrap().is_empty() {
self.stop_recv_loop
- .broadcast(true)
+ .send(true)
.log_err("could not write true to stop_recv_loop");
}
}
@@ -274,7 +274,7 @@ impl RecvLoop for ClientConn {
if inflight.is_empty() && self.must_exit.load(atomic::Ordering::SeqCst) {
self.stop_recv_loop
- .broadcast(true)
+ .send(true)
.log_err("could not write true to stop_recv_loop");
}
}
diff --git a/src/netapp.rs b/src/netapp.rs
index 0ddd447..5847f98 100644
--- a/src/netapp.rs
+++ b/src/netapp.rs
@@ -202,7 +202,7 @@ impl NetApp {
};
self.listen_params.store(Some(Arc::new(listen_params)));
- let mut listener = TcpListener::bind(listen_addr).await.unwrap();
+ let listener = TcpListener::bind(listen_addr).await.unwrap();
info!("Listening on {}", listen_addr);
loop {
diff --git a/src/peering/basalt.rs b/src/peering/basalt.rs
index 3c1fc9e..abfe1e4 100644
--- a/src/peering/basalt.rs
+++ b/src/peering/basalt.rs
@@ -321,7 +321,7 @@ impl Basalt {
async fn run_pushpull_loop(self: Arc<Self>) {
loop {
- tokio::time::delay_for(self.param.exchange_interval).await;
+ tokio::time::sleep(self.param.exchange_interval).await;
let peers = self.view.read().unwrap().sample(2);
if peers.len() == 2 {
@@ -368,7 +368,7 @@ impl Basalt {
async fn run_reset_loop(self: Arc<Self>) {
loop {
- tokio::time::delay_for(self.param.reset_interval).await;
+ tokio::time::sleep(self.param.reset_interval).await;
{
debug!("KYEV R {}", self.param.reset_count);
diff --git a/src/peering/fullmesh.rs b/src/peering/fullmesh.rs
index a4b9248..9b55180 100644
--- a/src/peering/fullmesh.rs
+++ b/src/peering/fullmesh.rs
@@ -241,7 +241,7 @@ impl FullMeshPeeringStrategy {
}
// 4. Sleep before next loop iteration
- tokio::time::delay_for(LOOP_DELAY).await;
+ tokio::time::sleep(LOOP_DELAY).await;
}
}
diff --git a/src/proto.rs b/src/proto.rs
index 7b8aa4b..bfef8e7 100644
--- a/src/proto.rs
+++ b/src/proto.rs
@@ -36,7 +36,7 @@ pub const PRIO_NORMAL: RequestPriority = 0x40;
pub const PRIO_BACKGROUND: RequestPriority = 0x80;
/// Priority: primary among given class
pub const PRIO_PRIMARY: RequestPriority = 0x00;
-/// Priority: secondary among given class (ex: `PRIO_HIGH || PRIO_SECONDARY`)
+/// Priority: secondary among given class (ex: `PRIO_HIGH | PRIO_SECONDARY`)
pub const PRIO_SECONDARY: RequestPriority = 0x01;
const MAX_CHUNK_SIZE: usize = 0x4000;
diff --git a/src/util.rs b/src/util.rs
index faeea79..ba485bf 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -32,9 +32,9 @@ where
/// )
/// ```
pub async fn await_exit(mut must_exit: watch::Receiver<bool>) {
- loop {
- if must_exit.recv().await == Some(true) {
- return;
+ while !*must_exit.borrow_and_update() {
+ if must_exit.changed().await.is_err() {
+ break;
}
}
}