realm_io: add optional brutal-shutdown feature

This commit is contained in:
zephyr
2022-04-27 00:04:13 +09:00
parent c4466152c9
commit cd00d9296a
4 changed files with 27 additions and 11 deletions
Generated
+5 -5
View File
@@ -888,7 +888,7 @@ dependencies = [
"mimalloc",
"pin-project",
"proxy-protocol",
"realm_io 0.2.5",
"realm_io 0.2.6",
"serde",
"serde_json",
"socket2 0.4.4",
@@ -905,7 +905,7 @@ dependencies = [
"lazy_static",
"log",
"pin-project",
"realm_io 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"realm_io 0.2.5",
"realm_syscall 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio",
"trust-dns-resolver 0.21.2",
@@ -914,6 +914,8 @@ dependencies = [
[[package]]
name = "realm_io"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "214919adf97309686e1f07abb4cf5245fd6a165e0b9ee9a50c98c949cf44eab2"
dependencies = [
"libc",
"tokio",
@@ -921,9 +923,7 @@ dependencies = [
[[package]]
name = "realm_io"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "214919adf97309686e1f07abb4cf5245fd6a165e0b9ee9a50c98c949cf44eab2"
version = "0.2.6"
dependencies = [
"libc",
"tokio",
+1
View File
@@ -86,6 +86,7 @@ transport = ["kaminari"]
transport-boost = []
proxy-protocol = ["haproxy"]
multi-thread = ["tokio/rt-multi-thread"]
brutal-shutdown = ["realm_io/brutal-shutdown"]
jemalloc = ["jemallocator"]
mi-malloc = ["mimalloc"]
+5 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "realm_io"
version = "0.2.5"
version = "0.2.6"
authors = ["zephyr <i@zephyr.moe>"]
description = "Realm's high performance IO collections."
repository = "https://github.com/zhboner/realm/realm_io"
@@ -16,3 +16,7 @@ tokio = "1.9"
[target.'cfg(unix)'.dependencies]
tokio = { version = "1.9", features = ["net"] }
[features]
default = []
brutal-shutdown = []
+16 -5
View File
@@ -118,12 +118,23 @@ where
let a_to_b = transfer(cx, a_to_b, a, b, ab_amt)?;
let b_to_a = transfer2::<B, SL, SR>(cx, b_to_a, b, a, ba_amt)?;
// It is not a problem if ready! returns early because transfer_one_direction for the
// other direction will keep returning TransferState::Done(count) in future calls to poll
ready!(a_to_b);
ready!(b_to_a);
// graceful shutdown
#[cfg(not(feature = "brutal-shutdown"))]
{
ready!(a_to_b);
ready!(b_to_a);
Poll::Ready(Ok(()))
}
Poll::Ready(Ok(()))
// brutal shutdown
#[cfg(feature = "brutal-shutdown")]
{
if a_to_b.is_ready() || b_to_a.is_ready() {
Poll::Ready(Ok(()))
}else {
Poll::Pending
}
}
}
}