-
Notifications
You must be signed in to change notification settings - Fork 93
Avoid forkIO
in bye
#477
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
Avoid forkIO
in bye
#477
Conversation
If the peer has disconnected, `bye` may throw `resource vanished` exceptions from a forked thread, whose top-level exception handler will print them to stdout. This suppresses that output and ensures that shutdown is best-effort only.
bae7adb
to
8d37801
Compare
Let me know if the changes I made are what you had in mind! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now LGTM!
Rebased and merged. |
Thanks @kazu-yamamoto! In the meantime, we realized that the behavior introduced by this PR might not be desirable. In particular, we might not want to swallow synchronous exceptions if the shutdown sequence itself is not the result of some other exception. I will open another PR tomorrow that attempts to address this. |
If you was able to provide test cases, it would be great. |
A bit of background for this PR. Suppose we have something like bracket (... setup ...) bye $ body If an exception is thrown in However, what we realized only after submitting: what happens if It's not entirely clear to me however what the right solution is. Even if we tell So, the path going forward as I see it:
@FinleyMcIlwaine , could you verify please if doing this throw-to-main-thread thing in |
0152e8d
to
8d37801
Compare
Implemented the throw-to-main-thread thing in #478, it also solves the exception output we were seeing in |
I should have written this first. I think the usage body = do
ctx <- contextNew
handshake ctx
something
bye ctx However, even I made this mistake. You can find my wrong examples in It's time to revisit this issue. Recently I'm not a fan of asynchronous exceptions, so I don't want to use |
I agree, that avoids the whole problem of trying to call However, we still then have the possibility of an exception arising in one of the auxiliary threads spawned by
Would that be okay with you? |
My plan is 1) AND 2). Not 1) OR 2). |
Yes, that is what I meant also :) |
For the first step, I removed |
@edsko @FinleyMcIlwaine What should we do next? |
@kazu-yamamoto sorry for the delay.
So I think once that call to |
@edsko Thanks. That's what I want to hear. Would you send a PR? |
Yup, will do! |
@kazu-yamamoto I opened a PR removing the |
bye
forkIO
in bye
Closing with #480. |
If the peer has disconnected,
bye
may throwresource vanished
exceptions from a forked thread, whose top-level exception handler will print them to stdout. We are addressing this by removing theforkIO
s frombye
. The patch now exists at kazu'snew-bye
branch. This one has been marked as a draft in the meantime, and should be closed when that branch is merged.