Merge branch 'fix-async-std' into 'main'

fix compilation error with async-std

See merge request tpo/core/arti!723
This commit is contained in:
eta 2022-09-07 17:16:28 +00:00
commit d9c140992f
3 changed files with 6 additions and 2 deletions

1
Cargo.lock generated
View File

@ -103,6 +103,7 @@ dependencies = [
"secmem-proc",
"serde",
"serde_json",
"signal-hook",
"signal-hook-async-std",
"tokio",
"toml",

View File

@ -21,6 +21,7 @@ async-std = [
"tor-rtcompat/async-std",
"async-ctrlc",
"once_cell",
"signal-hook",
"signal-hook-async-std",
]
dns-proxy = ["trust-dns-proto"]
@ -61,6 +62,7 @@ rlimit = "0.8.3"
safelog = { path = "../safelog", version = "0.1.0" }
secmem-proc = { version = "0.1.1", optional = true }
serde = { version = "1.0.103", features = ["derive"] }
signal-hook = { version = "0.3", optional = true }
signal-hook-async-std = { version = "0.2", optional = true }
tokio-crate = { package = "tokio", version = "1.7", optional = true, features = ["signal"] }
tor-config = { path = "../tor-config", version = "0.6.0" }

View File

@ -88,9 +88,10 @@ pub(crate) fn sighup_stream() -> crate::Result<impl futures::Stream<Item = ()>>
Ok(futures::stream::poll_fn(move |ctx| signal.poll_recv(ctx)))
} else if #[cfg(all(feature="async-std", target_family = "unix"))] {
use signal_hook_async_std as s;
use signal_hook::consts::signal;
use futures::stream::StreamExt as _;
let mut signal = s::Signals::new(&[s::consts::signals::SIGHUP])?;
Ok(signals.map(|i| i*2))
let signal = s::Signals::new(&[signal::SIGHUP])?;
Ok(signal.map(|_| ()))
} else {
// Not unix or no backend, so we won't ever get a SIGHUP.
Ok(futures::stream::pending())