WIP: ws: split into features, other fixes

This commit is contained in:
Joakim Frostegård 2021-11-05 13:18:22 +01:00
parent 465cf5920d
commit 2bed6ccdc5
10 changed files with 76 additions and 25 deletions

View file

@ -1,11 +1,14 @@
use aquatic_common::access_list::update_access_list;
use cfg_if::cfg_if;
use signal_hook::{consts::SIGUSR1, iterator::Signals};
use crate::config::Config;
pub mod common;
pub mod config;
#[cfg(feature = "with-glommio")]
pub mod glommio;
#[cfg(feature = "with-mio")]
pub mod mio;
pub const APP_NAME: &str = "aquatic_ws: WebTorrent tracker";
@ -17,7 +20,13 @@ pub fn run(config: Config) -> ::anyhow::Result<()> {
});
}
let state = glommio::common::State::default();
cfg_if!(
if #[cfg(feature = "with-glommio")] {
let state = glommio::common::State::default();
} else {
let state = mio::common::State::default();
}
);
update_access_list(&config.access_list, &state.access_list)?;
@ -27,7 +36,13 @@ pub fn run(config: Config) -> ::anyhow::Result<()> {
let config = config.clone();
let state = state.clone();
::std::thread::spawn(move || glommio::run_inner(config, state));
cfg_if!(
if #[cfg(feature = "with-glommio")] {
::std::thread::spawn(move || glommio::run_inner(config, state));
} else {
::std::thread::spawn(move || mio::run(config, state));
}
);
}
for signal in &mut signals {