Skip to content

Commit 75c21b5

Browse files
committed
fix loom?
1 parent f188005 commit 75c21b5

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

tokio/src/runtime/task/harness.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -383,16 +383,14 @@ where
383383
// We call this in a separate block so that it runs after the task appears to have
384384
// completed and will still run if the destructor panics.
385385
#[cfg(tokio_unstable)]
386-
self.trailer().hooks.with_mut(|ptr| unsafe {
387-
ptr.as_mut().and_then(|x| {
388-
x.as_mut().map(|x| {
389-
let _ = panic::catch_unwind(panic::AssertUnwindSafe(|| {
390-
x.on_task_terminate(&mut OnTaskTerminateContext {
391-
_phantom: Default::default(),
392-
})
393-
}));
394-
})
395-
})
386+
let _ = with_task_hooks(|t| {
387+
if let Some(hooks) = t {
388+
let _ = panic::catch_unwind(panic::AssertUnwindSafe(|| {
389+
hooks.on_task_terminate(&mut OnTaskTerminateContext {
390+
_phantom: Default::default(),
391+
})
392+
}));
393+
}
396394
});
397395

398396
// The task has completed execution and will no longer be scheduled.

0 commit comments

Comments
 (0)