Skip to content

Commit 40ef717

Browse files
committed
fix(runtime): leak instead of panic
1 parent ff47cb3 commit 40ef717

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

  • compio-runtime/src/runtime/scheduler

compio-runtime/src/runtime/scheduler/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,13 @@ impl WeakTaskQueue {
117117
#[cfg(feature = "notify-always")]
118118
notify.notify().ok();
119119
}
120-
} else {
121-
// We have to panic if the queue has been dropped, because we cannot drop the
122-
// runnable safely on another thread.
123-
let sync_queue = self.sync_queue.upgrade().unwrap();
120+
} else if let Some(sync_queue) = self.sync_queue.upgrade() {
124121
sync_queue.push(runnable);
125122
notify.notify().ok();
123+
} else {
124+
// We have to leak the runnable since it's not safe to drop it on another
125+
// thread.
126+
std::mem::forget(runnable);
126127
}
127128
}
128129
}

0 commit comments

Comments
 (0)