aquatic_udp: add privdrop failsafe timeout

This commit is contained in:
Joakim Frostegård 2021-10-15 02:59:13 +02:00
parent 3bb6c1994c
commit cedf60155e

View file

@ -26,6 +26,8 @@ pub fn run(config: Config) -> ::anyhow::Result<()> {
let num_bound_sockets = start_workers(config.clone(), state.clone())?;
if config.privileges.drop_privileges {
let mut counter = 0usize;
loop {
let sockets = num_bound_sockets.load(Ordering::SeqCst);
@ -39,6 +41,12 @@ pub fn run(config: Config) -> ::anyhow::Result<()> {
}
::std::thread::sleep(Duration::from_millis(10));
counter += 1;
if counter == 500 {
panic!("Sockets didn't bind in time for privilege drop.");
}
}
}