From 855be676da3c0652b29fe986ffced0ed192bcf54 Mon Sep 17 00:00:00 2001 From: Noah Kennedy Date: Fri, 2 May 2025 15:34:41 -0500 Subject: [PATCH] try lloyd's fix --- tokio/src/runtime/task/raw.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tokio/src/runtime/task/raw.rs b/tokio/src/runtime/task/raw.rs index ad2f30677..90b3477ec 100644 --- a/tokio/src/runtime/task/raw.rs +++ b/tokio/src/runtime/task/raw.rs @@ -215,8 +215,8 @@ impl RawTask { /// Safety: mutual exclusion is required to call this function. pub(crate) fn poll(self) { #[cfg(tokio_unstable)] - self.trailer().hooks.with_mut(|ptr| unsafe { - let _guard = ptr.as_mut().and_then(|x| { + let _guard = self.trailer().hooks.with_mut(|ptr| unsafe { + ptr.as_mut().and_then(|x| { x.as_mut().map(|x| { let _ = panic::catch_unwind(panic::AssertUnwindSafe(|| { x.before_poll(&mut BeforeTaskPollContext { @@ -228,12 +228,9 @@ impl RawTask { (&mut **x) as *mut (dyn TaskHookHarness + Send + Sync + 'static), )) }) - }); - - let vtable = self.header().vtable; - (vtable.poll)(self.ptr); + }) }); - #[cfg(not(tokio_unstable))] + unsafe { let vtable = self.header().vtable; (vtable.poll)(self.ptr);