This commit is contained in:
Christien Rioux
2023-08-27 16:39:50 -05:00
parent 8c366387eb
commit 3125c19f02
6 changed files with 94 additions and 37 deletions

View File

@@ -12,10 +12,11 @@ crate-type = ["cdylib", "staticlib", "rlib"]
[features]
# Common features
default = ["enable-crypto-vld0"]
default = ["enable-crypto-vld0", "rt-tokio"]
rt-async-std = [
"async-std",
"async-std-resolver",
"trust-dns-resolver",
"async_executors/async_std",
"rtnetlink/smol_socket",
"veilid-tools/rt-async-std",
@@ -52,7 +53,9 @@ network-result-extra = ["veilid-tools/network-result-extra"]
[dependencies]
# Tools
veilid-tools = { path = "../veilid-tools", features = ["tracing"] }
veilid-tools = { path = "../veilid-tools", features = [
"tracing",
], default-features = false }
paste = "1.0.14"
once_cell = "1.18.0"
owning_ref = "0.4.1"

View File

@@ -18,6 +18,7 @@ cfg_if! {
cfg_if! {
if #[cfg(feature="rt-async-std")] {
use async_std_resolver::{config, resolver, resolver_from_system_conf, AsyncStdResolver as AsyncResolver};
use trust_dns_resolver::error::ResolveErrorKind;
} else if #[cfg(feature="rt-tokio")] {
use trust_dns_resolver::{config, TokioAsyncResolver as AsyncResolver, error::ResolveError, error::ResolveErrorKind};

View File

@@ -132,6 +132,30 @@ impl Network {
}
};
#[cfg(all(feature = "rt-async-std", unix))]
{
// async-std does not directly support linger on tcpsocket yet
use std::os::fd::AsRawFd;
use std::os::fd::FromRawFd;
if let Err(e) = unsafe { socket2::Socket::from_raw_fd(tcp_stream.as_raw_fd()) }
.set_linger(Some(core::time::Duration::from_secs(0)))
{
log_net!(debug "Couldn't set TCP linger: {}", e);
return;
}
}
#[cfg(all(feature = "rt-async-std", windows))]
{
// async-std does not directly support linger on tcpsocket yet
use std::os::windows::io::AsRawSocket;
if let Err(e) = unsafe { socket2::socket_from_raw(tcp_stream.as_raw_socket()) }
.set_linger(Some(core::time::Duration::from_secs(0)))
{
log_net!(debug "Couldn't set TCP linger: {}", e);
return;
}
}
#[cfg(not(feature = "rt-async-std"))]
if let Err(e) = tcp_stream.set_linger(Some(core::time::Duration::from_secs(0))) {
log_net!(debug "Couldn't set TCP linger: {}", e);
return;