Skip to content

Commit

Permalink
Fix: default settings setup for Babeld
Browse files Browse the repository at this point in the history
This function was always going to fail because it was missing a return
statement on success and the timeout check would always fail.
  • Loading branch information
jkilpatr committed Jan 18, 2024
1 parent cf1dfbe commit 8827d25
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions rita_common/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,31 @@ pub fn apply_babeld_settings_defaults(babeld_port: u16, config: BabeldConfig) {
// many not be reachable due to just being started so we want to wait a bit, but not indefinately
const BABEL_CONTACT_TIMEOUT: Duration = Duration::from_secs(20);
let start = Instant::now();
while Instant::now() < start {
if let Ok(mut stream) = open_babel_stream(babeld_port, BABEL_CONTACT_TIMEOUT) {
if let Err(e) = babel_monitor::set_local_fee(&mut stream, config.local_fee) {
error!("Failed to set babel local fee with {:?}", e);
}
if let Err(e) = babel_monitor::set_metric_factor(&mut stream, config.metric_factor) {
error!("Failed to set babel metric factor with {:?}", e);
}
if let Err(e) =
babel_monitor::set_kernel_check_interval(&mut stream, config.kernel_check_interval)
{
error!("Failed to set babel kernel check interval with {:?}", e);
}
if let Err(e) =
babel_monitor::set_interface_defaults(&mut stream, config.interface_defaults)
{
error!("Failed to set babel interface defaults with {:?}", e);
while Instant::now() < start + BABEL_CONTACT_TIMEOUT {
match open_babel_stream(babeld_port, BABEL_CONTACT_TIMEOUT) {
Ok(mut stream) => {
if let Err(e) = babel_monitor::set_local_fee(&mut stream, config.local_fee) {
error!("Failed to set babel local fee with {:?}", e);
}
if let Err(e) = babel_monitor::set_metric_factor(&mut stream, config.metric_factor)
{
error!("Failed to set babel metric factor with {:?}", e);
}
if let Err(e) = babel_monitor::set_kernel_check_interval(
&mut stream,
config.kernel_check_interval,
) {
error!("Failed to set babel kernel check interval with {:?}", e);
}
if let Err(e) =
babel_monitor::set_interface_defaults(&mut stream, config.interface_defaults)
{
error!("Failed to set babel interface defaults with {:?}", e);
}
info!("Successfully completed babeld setup!");
return;
}
Err(e) => error!("Failed to connect to babel! {:?}", e),
}
}
panic!(
Expand Down

0 comments on commit 8827d25

Please sign in to comment.