Skip to content

Commit

Permalink
Remove a deadlock in RustAdvLoggerDxe
Browse files Browse the repository at this point in the history
  • Loading branch information
joschock committed Nov 11, 2023
1 parent 228a027 commit efe7746
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion AdvLoggerPkg/Crates/RustAdvancedLoggerDxe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ impl LockedAdvancedLogger {

// Log the debug output in `args` at the given log level.
fn log(&self, level: usize, args: fmt::Arguments) {
self.inner.lock().log(level, args)
// Note: tasks at higher TPL may interrupt logging of tasks at lower TPL. This could cause deadlock here, if the
// lower TPL thread is holding the lock and is interrupted at a higher TPL. For now, use try_lock() to avoid
// deadlock here. This has the downside of potentially dropping messages at higher TPL.
if let Some(mut logger) = self.inner.try_lock() {
logger.log(level, args)
}
}
}

Expand Down

0 comments on commit efe7746

Please sign in to comment.