nym
nym copied to clipboard
Remove all cancel unsafe calls from `select!`s
From all the select!s in the repository, there are at least 7 occurrences where there is a loop encapsulating the select! and at least two branches which don't break the loop (most of the select!s that catch the shutdown signal also break the loop, so those shouldn't be a problem).
One example:
while !self.shutdown.is_shutdown() {
tokio::select! {
action = self.incoming_actions.next() => ....
expired_ack = self.pending_acks_timers.next() => ....
....
}
}
In this case neither of the two has an unconditional break of the while loop, and both of them are not cancel safe:
incoming_actionsis afutures::channel::mpsc::UnboundedReceiver, which is not cancel safe and should replaced with itstokiocounterpart.pending_acks_timerslocally implementsStream, which is not cancel safe either
We should make sure that all the select! branches are either cancel safe, or at least they get cancelled in unrecoverable situations (such as shutdown).