Skip to content
Draft
Show file tree
Hide file tree
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
24 changes: 7 additions & 17 deletions profiling/src/profiling/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,23 +836,13 @@ impl Profiler {
}
}

fn join_collector_and_uploader(self, timeout: Duration) -> Result<(), JoinError> {
if self.should_join.load(Ordering::SeqCst) {
let result1 = thread_utils::join_timeout(self.time_collector_handle, timeout);
if let Err(err) = &result1 {
warn!("{err}, recent samples may be lost");
}

// Wait for the time_collector to join, since that will drop
// the sender half of the channel that the uploader is
// holding, allowing it to finish.
let result2 = thread_utils::join_timeout(self.uploader_handle, timeout);
if let Err(err) = &result2 {
warn!("{err}, recent samples are most likely lost");
}

let num_failures = result1.is_err() as usize + result2.is_err() as usize;
result2.and(result1).map_err(|_| JoinError { num_failures })
fn join_collector_and_uploader(self, _timeout: Duration) -> Result<(), JoinError> {
let result1 = self.time_collector_handle.join();
let result2 = self.uploader_handle.join();
if result1.is_err() || result2.is_err() {
Err(JoinError {
num_failures: result1.is_err() as usize + result2.is_err() as usize,
})
} else {
Ok(())
}
Expand Down
2 changes: 2 additions & 0 deletions profiling/src/profiling/thread_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ where
}
}

#[allow(unused)]
#[derive(thiserror::Error, Debug)]
#[error("timeout of {timeout_ms} ms reached when joining thread {thread}")]
pub struct TimeoutError {
Expand All @@ -61,6 +62,7 @@ pub struct TimeoutError {
/// Otherwise, it will leak the handle and return an error.
/// # Panics
/// If the thread being joined has panic'd, this will resume the panic.
#[allow(unused)]
pub fn join_timeout(handle: JoinHandle<()>, timeout: Duration) -> Result<(), TimeoutError> {
// After notifying the other threads, it's likely they'll need some time
// to respond adequately. Joining on the JoinHandle is supposed to be the
Expand Down
Loading