fn remove_hungup_and_drained_tubes<T, U>(
    events: &SmallVec<[TriggeredEvent<T>; 16]>,
    wait_ctx: &WaitContext<T>,
    tubes: &mut BTreeMap<usize, U>,
    tube_ids_to_remove: Vec<usize>,
    get_tube_id: fn(token: &T) -> Option<usize>
) -> Result<()>where
    T: EventToken,
    U: ReadNotifier,
Expand description

When control tubes hang up, we want to make sure that we’ve fully drained the underlying socket before removing it. This function also handles removing closed sockets in such a way that avoids phantom events.

tube_ids_to_remove is the set of ids that we already know should be removed (e.g. from getting a disconnect error on read).