-
Notifications
You must be signed in to change notification settings - Fork 342
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
Manually poll an UdpSocket is not working, but used to – regression? #955
Comments
OK, I pinned down where the regression occurs: It works fine with |
This "worked" previously because we used a hack, which was later on removed. Imagine there are 1000 tasks concurrently polling What you should do instead is store the future inside |
Thank you for the explanation! Storing the future was actually what I tried first, but ran into lifetime issues and then found that comment of yours. I'll try again storing the future then. |
OK, I found a way to circumvent the lifetime issues. I don't think its super elegant, but it works: I'm moving both the socket and the buffer into the future, getting it back when the future is ready. |
- The poll_next method of UdpFramed needs to store the socket.recv_from future, the old behavior of recreating the future on each poll is no longer supported. See [this issue](async-rs/async-std#955) for details. - I couldn't get the future to work with BytesMut because all references or raw pointers seem to be not Send which is needed for it to work across the await. Thus I changed to a vec, which should be fine too, but not sure.
I found a more elegant way to store and poll the future than in the example linked above, see https://github.com/Frando/async-osc/blob/72ec4cc7aac65891a241daab9d180b2ace636c70/src/udp.rs if interested. Closing this, thanks for the help 🙂 |
Hi,
I need to manually poll an UdpSocket to drive it from a
poll_next
method.I've read #636, where @stjepang suggests to just recreate the future on each poll. I've set up an example here:
https://github.com/Frando/async-std-udp-test/blob/main/src/main.rs
When pinning
async_std
to=1.6.2
this works as it should. When changing theasync_std
version to1.9
, the example fails: The reading side is not woken after a firstread_from
returnsPoll::Pending
.Is there something I'm missing, or is this a regression?
I'll try to track down from which version it fails (the 1.6.2 comes from another crate that depended on this version, from where I started debugging why things don't work anymore).
The text was updated successfully, but these errors were encountered: