mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
io: fix safety of LinkedList
drain_filter API (#5832)
The `drain_filter` method on the internal `LinkedList` type passes a `&mut` reference to the node type. However, the `LinkedList` is intended to be used with nodes that are shared in other ways. For example `task::Header` is accessible concurrently from multiple threads. Currently, the only usage of `drain_filter` is in a case where `&mut` access is safe, so this change is to help prevent future bugs and tighten up the safety of internal utilities.
This commit is contained in:
parent
1bfe778acb
commit
ec1f52e1d3
@ -307,7 +307,7 @@ cfg_io_driver_impl! {
|
||||
impl<T: Link> LinkedList<T, T::Target> {
|
||||
pub(crate) fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F>
|
||||
where
|
||||
F: FnMut(&mut T::Target) -> bool,
|
||||
F: FnMut(&T::Target) -> bool,
|
||||
{
|
||||
let curr = self.head;
|
||||
DrainFilter {
|
||||
@ -321,7 +321,7 @@ cfg_io_driver_impl! {
|
||||
impl<'a, T, F> Iterator for DrainFilter<'a, T, F>
|
||||
where
|
||||
T: Link,
|
||||
F: FnMut(&mut T::Target) -> bool,
|
||||
F: FnMut(&T::Target) -> bool,
|
||||
{
|
||||
type Item = T::Handle;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user