fn remove_hungup_and_drained_tubes<T, U>(
    events: &SmallVec<[TriggeredEvent<T>; 16]>,
    wait_ctx: &WaitContext<T>,
    tubes: &mut Vec<U>,
    tube_indices_to_remove: Vec<usize>,
    get_tube_index: fn(token: &T) -> Option<usize>,
    make_token_for_tube: fn(_: usize) -> T
) -> 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_indices_to_remove is the set of indices that we already know should be removed (e.g. from getting a disconnect error on read).