Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benph/unwrap to expect #3693

Merged
merged 2 commits into from
Mar 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions massa-bootstrap/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ impl BootstrapManager {

// when the runtime is dropped at the end of this stop, the listener is auto-aborted

// unwrap() effectively passes up a panic from the thread being handled
self.update_handle.join().unwrap()?;
self.update_handle
.join()
.expect("in BootstrapManager::stop() joining on updater thread")?;

// unwrap() effectively passes up a panic from the thread being handled
self.main_handle.join().unwrap()
self.main_handle
.join()
.expect("in BootstrapManager::stop() joining on bootstrap main-loop thread")
}
}

Expand Down Expand Up @@ -158,9 +160,7 @@ pub async fn start_bootstrap_server(
};
res
})
// the non-builder spawn doesn't return a Result, and documentation states that
// it's an error at the OS level.
.unwrap();
.expect("in `start_bootstrap_server`, OS failed to spawn list-updater thread");
let listen_rt_handle = bs_server_runtime.handle().clone();
let listen_handle = thread::Builder::new()
.name("bs_listener".to_string())
Expand All @@ -171,9 +171,7 @@ pub async fn start_bootstrap_server(
listen_rt_handle.block_on(BootstrapServer::run_listener(listener, listener_tx));
res
})
// the non-builder spawn doesn't return a Result, and documentation states that
// it's an error at the OS level.
.unwrap();
.expect("in `start_bootstrap_server`, OS failed to spawn listener thread");

let main_handle = thread::Builder::new()
.name("bs-main-loop".to_string())
Expand All @@ -193,9 +191,7 @@ pub async fn start_bootstrap_server(
}
.run_loop(max_bootstraps)
})
// the non-builder spawn doesn't return a Result, and documentation states that
// it's an error at the OS level.
.unwrap();
.expect("in `start_bootstrap_server`, OS failed to spawn main-loop thread");
// Give the runtime to the bootstrap manager, otherwise it will be dropped, forcibly aborting the spawned tasks.
// TODO: make the tasks sync, so the runtime is redundant
Ok(Some(BootstrapManager {
Expand Down