-
Notifications
You must be signed in to change notification settings - Fork 156
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
Failing to check for closed socket causes future to spin, hogging executor thread #270
Comments
I think that your two futures in One of the main architectural differences between Tokio and Smol is that Tokio's reactor uses edge-triggered polling while Smol's uses oneshot polling. The intuitive way to think about this is:
In most cases the user facing differences between these two approaches is not noticeable. However, since there is no more incoming data Tokio returns |
This was just a minimal example. In my actual code, I perform some modifications to the stream, so
Yes, I was at least tangentially aware of this. I encountered the problem above in integration tests using
I thought this might be a conscious design decision, but I wasn't sure. Thanks for clarifying. I'll be sure to keep that difference in mind in the future. Thanks for answering my question. |
Hi,
While switching from Tokio to smol, I encountered an issue. My integration tests still worked, but only when run one at a time. When running multiple tests, some of them would hang indefinitely.
I traced the issue to a spawned future that was spinning, hogging the global executor thread. I'm not sure if this is strictly a problem with my code, or if the behavior of smol is non-ideal in this case.
Here is a minimal reproduction of the issue:
If you run this with smol 1.3.0 and
cargo run
, you will see that onlyDone a/d
completes. There are two ways to fix the problem, either increaseSMOL_THREADS
to at least 3, or add the commented lines referenced by theFIXME
notes.The problem seems to be that the spawned futures are polled even after the
UnixSocket
s are closed, so the calls toread
return zero. Since I don't check for zero and exit, the future begins to spin.This is not a problem for Tokio. To me, that suggests that it is either wrong or at least non-ideal to continue polling the futures after the socket is dropped. But maybe this is just a different design decision? I'm not sure.
The text was updated successfully, but these errors were encountered: