|
|
|
@ -47,7 +47,6 @@ use dnsstamps::{InformalProperty, WithInformalProperty};
|
|
|
|
|
use failure::{bail, ensure};
|
|
|
|
|
use futures::join;
|
|
|
|
|
use futures::prelude::*;
|
|
|
|
|
use futures::FutureExt;
|
|
|
|
|
use parking_lot::Mutex;
|
|
|
|
|
use parking_lot::RwLock;
|
|
|
|
|
use privdrop::PrivDrop;
|
|
|
|
@ -268,8 +267,8 @@ async fn tcp_acceptor(globals: Arc<Globals>, tcp_listener: TcpListener) -> Resul
|
|
|
|
|
Ok(())
|
|
|
|
|
};
|
|
|
|
|
let fut_abort = rx;
|
|
|
|
|
let fut_all = future::select(FutureExt::boxed(fut), fut_abort).timeout(timeout);
|
|
|
|
|
runtime.spawn(FutureExt::map(fut_all, move |_| {
|
|
|
|
|
let fut_all = future::select(fut.boxed(), fut_abort).timeout(timeout);
|
|
|
|
|
runtime.spawn(fut_all.map(move |_| {
|
|
|
|
|
concurrent_connections.fetch_sub(1, Ordering::Relaxed);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
@ -312,8 +311,8 @@ async fn udp_acceptor(
|
|
|
|
|
let concurrent_connections = concurrent_connections.clone();
|
|
|
|
|
let fut = handle_client_query(globals, client_ctx, packet);
|
|
|
|
|
let fut_abort = rx;
|
|
|
|
|
let fut_all = future::select(FutureExt::boxed(fut), fut_abort).timeout(timeout);
|
|
|
|
|
runtime.spawn(FutureExt::map(fut_all, move |_| {
|
|
|
|
|
let fut_all = future::select(fut.boxed(), fut_abort).timeout(timeout);
|
|
|
|
|
runtime.spawn(fut_all.map(move |_| {
|
|
|
|
|
concurrent_connections.fetch_sub(1, Ordering::Relaxed);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
@ -325,14 +324,8 @@ async fn start(
|
|
|
|
|
listeners: Vec<(TcpListener, std::net::UdpSocket)>,
|
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
|
for listener in listeners {
|
|
|
|
|
runtime.spawn(FutureExt::map(
|
|
|
|
|
tcp_acceptor(globals.clone(), listener.0),
|
|
|
|
|
|_| {},
|
|
|
|
|
));
|
|
|
|
|
runtime.spawn(FutureExt::map(
|
|
|
|
|
udp_acceptor(globals.clone(), listener.1),
|
|
|
|
|
|_| {},
|
|
|
|
|
));
|
|
|
|
|
runtime.spawn(tcp_acceptor(globals.clone(), listener.0).map(|_| {}));
|
|
|
|
|
runtime.spawn(udp_acceptor(globals.clone(), listener.1).map(|_| {}));
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
@ -571,13 +564,14 @@ fn main() -> Result<(), Error> {
|
|
|
|
|
if !state_is_new {
|
|
|
|
|
updater.update();
|
|
|
|
|
}
|
|
|
|
|
runtime.spawn(FutureExt::map(
|
|
|
|
|
start(globals, runtime.clone(), listeners).map_err(|e| {
|
|
|
|
|
error!("Unable to start the service: [{}]", e);
|
|
|
|
|
std::process::exit(1);
|
|
|
|
|
}),
|
|
|
|
|
|_| (),
|
|
|
|
|
));
|
|
|
|
|
runtime.spawn(
|
|
|
|
|
start(globals, runtime.clone(), listeners)
|
|
|
|
|
.map_err(|e| {
|
|
|
|
|
error!("Unable to start the service: [{}]", e);
|
|
|
|
|
std::process::exit(1);
|
|
|
|
|
})
|
|
|
|
|
.map(|_| ()),
|
|
|
|
|
);
|
|
|
|
|
runtime.block_on(updater.run());
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|