Skip to content
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
21 changes: 17 additions & 4 deletions rust/ittapi/src/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,20 @@ impl Jit {
let data = event.data();
log::trace!("notify_event: tag={:?}", tag);
let res = unsafe { ittapi_sys::iJIT_NotifyEvent(tag, data) };
if res == 1 {
Ok(())
} else {
anyhow::bail!("error when notifying event")
match event {
EventType::MethodLoadFinished(_) => {
// Documentation of the `iJIT_NotifyEvent` says that the return code is undefined
// for this particular event, so we can't distinguish failures from successes.
// Hope for the best.
Ok(())
}
EventType::Shutdown => {
if res == 1 {
Ok(())
} else {
anyhow::bail!("error when notifying event with tag {tag}: return code = {res}");
}
}
}
}

Expand All @@ -61,6 +71,9 @@ impl Jit {
///
/// May fail if the ITT library fails to notify the shutdown event.
pub fn shutdown(&mut self) -> anyhow::Result<()> {
if self.shutdown_complete {
return Ok(());
}
let res = self.notify_event(EventType::Shutdown);
if res.is_ok() {
self.shutdown_complete = true;
Expand Down