aquatic_udp: feature-gate glommio version

This commit is contained in:
Joakim Frostegård 2021-10-21 15:26:16 +02:00
parent 047d138b2b
commit 81b7777a4a
3 changed files with 16 additions and 4 deletions

3
Cargo.lock generated
View file

@ -159,6 +159,7 @@ dependencies = [
"aquatic_cli_helpers", "aquatic_cli_helpers",
"aquatic_common", "aquatic_common",
"aquatic_udp_protocol", "aquatic_udp_protocol",
"cfg-if",
"crossbeam-channel", "crossbeam-channel",
"futures-lite", "futures-lite",
"glommio", "glommio",
@ -796,7 +797,7 @@ checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7"
[[package]] [[package]]
name = "glommio" name = "glommio"
version = "0.6.0" version = "0.6.0"
source = "git+https://github.com/DataDog/glommio.git#4e6b14772da2f4325271fbcf12d24cf91ed466e5" source = "git+https://github.com/DataDog/glommio.git?rev=4e6b14772da2f4325271fbcf12d24cf91ed466e5#4e6b14772da2f4325271fbcf12d24cf91ed466e5"
dependencies = [ dependencies = [
"ahash 0.7.6", "ahash 0.7.6",
"bitflags", "bitflags",

View file

@ -14,11 +14,15 @@ path = "src/lib/lib.rs"
[[bin]] [[bin]]
name = "aquatic_udp" name = "aquatic_udp"
[features]
with-glommio = ["glommio", "futures-lite"]
[dependencies] [dependencies]
anyhow = "1" anyhow = "1"
aquatic_cli_helpers = "0.1.0" aquatic_cli_helpers = "0.1.0"
aquatic_common = "0.1.0" aquatic_common = "0.1.0"
aquatic_udp_protocol = "0.1.0" aquatic_udp_protocol = "0.1.0"
cfg-if = "1"
crossbeam-channel = "0.5" crossbeam-channel = "0.5"
hashbrown = "0.11.2" hashbrown = "0.11.2"
hex = "0.4" hex = "0.4"
@ -33,8 +37,8 @@ rand = { version = "0.8", features = ["small_rng"] }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
socket2 = { version = "0.4.1", features = ["all"] } socket2 = { version = "0.4.1", features = ["all"] }
glommio = { git = "https://github.com/DataDog/glommio.git" } glommio = { git = "https://github.com/DataDog/glommio.git", rev = "4e6b14772da2f4325271fbcf12d24cf91ed466e5", optional = true }
futures-lite = "1" futures-lite = { version = "1", optional = true }
[dev-dependencies] [dev-dependencies]
quickcheck = "1.0" quickcheck = "1.0"

View file

@ -4,6 +4,7 @@ use aquatic_common::access_list::{AccessListArcSwap, AccessListMode, AccessListQ
pub mod common; pub mod common;
pub mod config; pub mod config;
#[cfg(all(feature = "with-glommio", target_os = "linux"))]
pub mod glommio; pub mod glommio;
pub mod mio; pub mod mio;
@ -12,7 +13,13 @@ use config::Config;
pub const APP_NAME: &str = "aquatic_udp: UDP BitTorrent tracker"; pub const APP_NAME: &str = "aquatic_udp: UDP BitTorrent tracker";
pub fn run(config: Config) -> ::anyhow::Result<()> { pub fn run(config: Config) -> ::anyhow::Result<()> {
glommio::run(config) cfg_if::cfg_if! {
if #[cfg(all(feature = "with-glommio", target_os = "linux"))] {
glommio::run(config)
} else {
mio::run(config)
}
}
} }
pub fn update_access_list(config: &Config, access_list: &Arc<AccessListArcSwap>) { pub fn update_access_list(config: &Config, access_list: &Arc<AccessListArcSwap>) {