diff --git a/Cargo.lock b/Cargo.lock index 1baa87a..1c49d63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -159,6 +159,7 @@ dependencies = [ "aquatic_cli_helpers", "aquatic_common", "aquatic_udp_protocol", + "cfg-if", "crossbeam-channel", "futures-lite", "glommio", @@ -796,7 +797,7 @@ checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" [[package]] name = "glommio" 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 = [ "ahash 0.7.6", "bitflags", diff --git a/aquatic_udp/Cargo.toml b/aquatic_udp/Cargo.toml index a1bd561..a79294c 100644 --- a/aquatic_udp/Cargo.toml +++ b/aquatic_udp/Cargo.toml @@ -14,11 +14,15 @@ path = "src/lib/lib.rs" [[bin]] name = "aquatic_udp" +[features] +with-glommio = ["glommio", "futures-lite"] + [dependencies] anyhow = "1" aquatic_cli_helpers = "0.1.0" aquatic_common = "0.1.0" aquatic_udp_protocol = "0.1.0" +cfg-if = "1" crossbeam-channel = "0.5" hashbrown = "0.11.2" hex = "0.4" @@ -33,8 +37,8 @@ rand = { version = "0.8", features = ["small_rng"] } serde = { version = "1", features = ["derive"] } socket2 = { version = "0.4.1", features = ["all"] } -glommio = { git = "https://github.com/DataDog/glommio.git" } -futures-lite = "1" +glommio = { git = "https://github.com/DataDog/glommio.git", rev = "4e6b14772da2f4325271fbcf12d24cf91ed466e5", optional = true } +futures-lite = { version = "1", optional = true } [dev-dependencies] quickcheck = "1.0" diff --git a/aquatic_udp/src/lib/lib.rs b/aquatic_udp/src/lib/lib.rs index 41003fc..3ea2bba 100644 --- a/aquatic_udp/src/lib/lib.rs +++ b/aquatic_udp/src/lib/lib.rs @@ -4,6 +4,7 @@ use aquatic_common::access_list::{AccessListArcSwap, AccessListMode, AccessListQ pub mod common; pub mod config; +#[cfg(all(feature = "with-glommio", target_os = "linux"))] pub mod glommio; pub mod mio; @@ -12,7 +13,13 @@ use config::Config; pub const APP_NAME: &str = "aquatic_udp: UDP BitTorrent tracker"; 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) {