Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle async cancellation in select #7

Open
voidc opened this issue Feb 9, 2022 · 0 comments
Open

Handle async cancellation in select #7

voidc opened this issue Feb 9, 2022 · 0 comments

Comments

@voidc
Copy link
Member

voidc commented Feb 9, 2022

Certain uses of the select macro do not handle async cancellation correctly which may lead to data loss.
(also see https://blog.yoshuawuyts.com/futures-concurrency-3/)

allium/src/onion/circuit.rs

Lines 165 to 172 in ea308e6

tokio::select! {
msg = self.in_circuit.accept_opaque() => self.handle_in_circuit(msg).await?,
msg = out_circuit.accept_opaque() => self.handle_out_circuit(msg).await?,
_ = &mut delay => {
self.handle_timeout().await;
break;
},
}

For example here, accept_opaque is not cancellation safe which causes data loss in the not-selected future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant