Skip to content

Commit

Permalink
also add liveness-idle mode to NTP pool
Browse files Browse the repository at this point in the history
  • Loading branch information
squell authored and davidv1992 committed Jan 10, 2024
1 parent 7eedb38 commit b4ed19e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions ntpd/src/daemon/spawn/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,16 @@ impl PoolSpawner {
std::time::Duration::from_secs(60)
};

wait_period = Ord::min(2 * wait_period, wait_period_max);
let peers_needed = self.config.max_peers - self.current_peers.len();
if peers_needed > 0 {
warn!(peers_needed, "could not fully fill pool");
wait_period *= 2;
if wait_period > wait_period_max {
warn!(peers_needed, "could not fully fill pool, giving up");
//NOTE: maybe we want to communicate this up the call chain?
return Ok(());
} else {
warn!(peers_needed, "could not fully fill pool, waiting");
}
tokio::time::sleep(wait_period).await;
} else {
return Ok(());
Expand All @@ -118,6 +124,14 @@ impl BasicSpawner for PoolSpawner {
Ok(())
}

async fn handle_idle(
&mut self,
action_tx: &mpsc::Sender<SpawnEvent>,
) -> Result<(), PoolSpawnError> {
self.fill_pool(action_tx).await?;
Ok(())
}

async fn handle_peer_removed(
&mut self,
removed_peer: PeerRemovedEvent,
Expand Down

0 comments on commit b4ed19e

Please sign in to comment.