-
Notifications
You must be signed in to change notification settings - Fork 608
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
[Bug] Infinite loop in polling function of Forward
#2552
Comments
hecrj
added a commit
to iced-rs/iced
that referenced
this issue
May 27, 2022
`StreamExt::forward` will keep polling a ready `Stream` in a loop. If the `Stream` is always ready, the `poll` method of `Forward` effectively blocks (see rust-lang/futures-rs#2552). The fix consists in manually implementing a simpler version of `Forward`.
hecrj
added a commit
to iced-rs/iced
that referenced
this issue
May 27, 2022
`StreamExt::forward` will keep polling a ready `Stream` in a loop. If the `Stream` is always ready, the `poll` method of `Forward` effectively blocks (see rust-lang/futures-rs#2552). The fix consists in manually implementing a simpler version of `Forward`.
Thanks for the report. The way good than yield per poll to fix this is to limit iterations. See tokio-rs/tokio#3625 for more. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here describes an scenario that hangs
stream.forward(sink)
in the polling function ofForward
(code). The code below is simplified version of the polling function. It goes back and forth between part A and B in the case that thestream
always returns an item when being polled, andsink
is always ready to receive an item. There is no chance to escape the loop.A simple experiment can be done in the example below, in which the polling of future
fut1
never ends. The futurefut2
has no chance to be executed.A simple fix is to remove the loop and call
cx.waker().wake_by_ref()
to request polling next time. It slightly adds up runtime cost but effectively eliminates the hanging issue.The text was updated successfully, but these errors were encountered: