Skip to content

Commit

Permalink
Merge pull request #40 from NLnetLabs/gracefully-handle-unnamed-threads
Browse files Browse the repository at this point in the history
Replace unwraps on thread name() with unwrap_or
  • Loading branch information
density215 authored Nov 20, 2024
2 parents 11d0896 + d94c5f6 commit c3d42bb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/local_array/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ macro_rules! insert_match {
if log_enabled!(log::Level::Trace) {
if local_retry_count > 0 {
trace!("{} contention: Node already exists {}",
std::thread::current().name().unwrap(), node_id
std::thread::current().name().unwrap_or("unnamed-thread"), node_id
)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/local_array/store/atomic_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<AF: AddressFamily, S: Stride> NodeSet<AF, S> {
if log_enabled!(log::Level::Debug) {
debug!(
"{} store: creating space for {} nodes",
std::thread::current().name().unwrap(),
std::thread::current().name().unwrap_or("unnamed-thread"),
1 << p2_size
);
}
Expand Down Expand Up @@ -144,15 +144,15 @@ impl<AF: AddressFamily, M: crate::prefix_record::Meta> StoredPrefix<AF, M> {
let next_bucket: PrefixSet<AF, M> = if next_level > 0 {
debug!(
"{} store: INSERT with new bucket of size {} at prefix len {}",
std::thread::current().name().unwrap(),
std::thread::current().name().unwrap_or("unnamed-thread"),
1 << (next_level - this_level),
pfx_id.get_len()
);
PrefixSet::init(next_level - this_level)
} else {
debug!(
"{} store: INSERT at LAST LEVEL with empty bucket at prefix len {}",
std::thread::current().name().unwrap(),
std::thread::current().name().unwrap_or("unnamed-thread"),
pfx_id.get_len()
);
PrefixSet::init(next_level - this_level)
Expand Down
12 changes: 6 additions & 6 deletions src/local_array/store/custom_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ impl<
if log_enabled!(log::Level::Trace) {
debug!(
"{} store: Store node {}: {:?} mui {}",
std::thread::current().name().unwrap(),
std::thread::current().name().unwrap_or("unnamed-thread"),
id,
next_node,
multi_uniq_id
Expand Down Expand Up @@ -461,7 +461,7 @@ impl<
if log_enabled!(log::Level::Trace) {
trace!(
"{} store: Retrieve node {} from l{}",
std::thread::current().name().unwrap(),
std::thread::current().name().unwrap_or("unnamed-thread"),
id,
id.get_id().1
);
Expand Down Expand Up @@ -511,7 +511,7 @@ impl<
if log_enabled!(log::Level::Trace) {
trace!(
"{} store: Retrieve node {} from l{} for mui {}",
std::thread::current().name().unwrap(),
std::thread::current().name().unwrap_or("unnamed-thread"),
id,
id.get_id().1,
mui
Expand Down Expand Up @@ -562,7 +562,7 @@ impl<
if log_enabled!(log::Level::Trace) {
trace!(
"{} store: Retrieve node mut {} from l{}",
std::thread::current().name().unwrap(),
std::thread::current().name().unwrap_or("unnamed-thread"),
id,
id.get_id().1
);
Expand Down Expand Up @@ -652,7 +652,7 @@ impl<
if log_enabled!(log::Level::Debug) {
debug!(
"{} store: Create new prefix record",
std::thread::current().name().unwrap()
std::thread::current().name().unwrap_or("unnamed-thread")
);
}

Expand All @@ -678,7 +678,7 @@ impl<
if log_enabled!(log::Level::Debug) {
debug!(
"{} store: Found existing prefix record for {}/{}",
std::thread::current().name().unwrap(),
std::thread::current().name().unwrap_or("unnamed-thread"),
prefix.get_net(),
prefix.get_len()
);
Expand Down
2 changes: 1 addition & 1 deletion src/local_array/store/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ macro_rules! store_node_closure {
if log_enabled!(log::Level::Trace) {
trace!("
{} store: Node here exists {:?}",
std::thread::current().name().unwrap(),
std::thread::current().name().unwrap_or("unnamed-thread"),
stored_node.node_id
);
trace!("node_id {:?}", stored_node.node_id.get_id());
Expand Down
4 changes: 2 additions & 2 deletions src/local_array/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,12 @@ impl<
Err(err) => {
if log_enabled!(log::Level::Error) {
error!("{} failing to store (intermediate) node {}. Giving up this node. This shouldn't happen!",
std::thread::current().name().unwrap(),
std::thread::current().name().unwrap_or("unnamed-thread"),
cur_i,
);
error!(
"{} {}",
std::thread::current().name().unwrap(),
std::thread::current().name().unwrap_or("unnamed-thread"),
err
);
}
Expand Down

0 comments on commit c3d42bb

Please sign in to comment.