Improve deadlock detection output (#7515)
This commit is contained in:
parent
d5b0a6f446
commit
9cc7f2ec16
|
|
@ -101,7 +101,6 @@ impl BytesLoader for EhttpLoader {
|
||||||
{
|
{
|
||||||
let entry = entry.get_mut();
|
let entry = entry.get_mut();
|
||||||
*entry = Poll::Ready(result);
|
*entry = Poll::Ready(result);
|
||||||
ctx.request_repaint();
|
|
||||||
log::trace!("Finished loading {uri:?}");
|
log::trace!("Finished loading {uri:?}");
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,6 @@ impl BytesLoader for FileLoader {
|
||||||
if let std::collections::hash_map::Entry::Occupied(mut entry) = cache.entry(uri.clone()) {
|
if let std::collections::hash_map::Entry::Occupied(mut entry) = cache.entry(uri.clone()) {
|
||||||
let entry = entry.get_mut();
|
let entry = entry.get_mut();
|
||||||
*entry = Poll::Ready(result);
|
*entry = Poll::Ready(result);
|
||||||
ctx.request_repaint();
|
|
||||||
log::trace!("Finished loading {uri:?}");
|
log::trace!("Finished loading {uri:?}");
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,12 @@ impl<T> Mutex<T> {
|
||||||
#[cfg_attr(debug_assertions, track_caller)]
|
#[cfg_attr(debug_assertions, track_caller)]
|
||||||
pub fn lock(&self) -> MutexGuard<'_, T> {
|
pub fn lock(&self) -> MutexGuard<'_, T> {
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
self.0
|
self.0.try_lock_for(DEADLOCK_DURATION).unwrap_or_else(|| {
|
||||||
.try_lock_for(DEADLOCK_DURATION)
|
panic!(
|
||||||
.expect("Looks like a deadlock!")
|
"DEBUG PANIC: Failed to acquire Mutex after {}s. Deadlock?",
|
||||||
|
DEADLOCK_DURATION.as_secs()
|
||||||
|
)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
self.0.lock()
|
self.0.lock()
|
||||||
}
|
}
|
||||||
|
|
@ -74,9 +77,12 @@ impl<T: ?Sized> RwLock<T> {
|
||||||
#[cfg_attr(debug_assertions, track_caller)]
|
#[cfg_attr(debug_assertions, track_caller)]
|
||||||
pub fn read(&self) -> RwLockReadGuard<'_, T> {
|
pub fn read(&self) -> RwLockReadGuard<'_, T> {
|
||||||
let guard = if cfg!(debug_assertions) {
|
let guard = if cfg!(debug_assertions) {
|
||||||
self.0
|
self.0.try_read_for(DEADLOCK_DURATION).unwrap_or_else(|| {
|
||||||
.try_read_for(DEADLOCK_DURATION)
|
panic!(
|
||||||
.expect("Looks like a deadlock!")
|
"DEBUG PANIC: Failed to acquire RwLock read after {}s. Deadlock?",
|
||||||
|
DEADLOCK_DURATION.as_secs()
|
||||||
|
)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
self.0.read()
|
self.0.read()
|
||||||
};
|
};
|
||||||
|
|
@ -91,9 +97,12 @@ impl<T: ?Sized> RwLock<T> {
|
||||||
#[cfg_attr(debug_assertions, track_caller)]
|
#[cfg_attr(debug_assertions, track_caller)]
|
||||||
pub fn write(&self) -> RwLockWriteGuard<'_, T> {
|
pub fn write(&self) -> RwLockWriteGuard<'_, T> {
|
||||||
let guard = if cfg!(debug_assertions) {
|
let guard = if cfg!(debug_assertions) {
|
||||||
self.0
|
self.0.try_write_for(DEADLOCK_DURATION).unwrap_or_else(|| {
|
||||||
.try_write_for(DEADLOCK_DURATION)
|
panic!(
|
||||||
.expect("Looks like a deadlock!")
|
"DEBUG PANIC: Failed to acquire RwLock write after {}s. Deadlock?",
|
||||||
|
DEADLOCK_DURATION.as_secs()
|
||||||
|
)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
self.0.write()
|
self.0.write()
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue