Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
KTOR-8135 Socket accept not throwing error on socket close on native #4637
KTOR-8135 Socket accept not throwing error on socket close on native #4637
Changes from all commits
afd0952
6b17359
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I think it's better to use
cancel
instead ofclose
herethis will also allow to revert
incoming
to useReceiveChannel
to respect the contractThere 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.
I think the close makes sense here to keep the exception in the same family as JVM (currently throws a
java.nio.channels.ClosedChannelException
) since cancel would throw a cancellation exception instead. Maybe it ought to go on line 66 in lieu of the cancel call, or maybe we should just use cancellation exceptions everywhere instead of IOException, though it seems leaving it with IOException would be the least disruptive change for now.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.
I went for IOException to keep it consistent with JVM. I don't think a CancellationException makes sense because calling
accept
on a closed socket should not be ignored as it is an error.I didn't put it in line 66 as I am not sure whether this could be called in situations other than a close.
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.
However, there are more inconsistencies. For example
attachForReading
/attachForWriting
on sockets. On some platforms they are stopped (withCancellationException
), but on some platforms nothing happens. On iOS this even causes TCP sockets to hang when closed, which I would say is a bug, https://youtrack.jetbrains.com/issue/KTOR-8144. Trying to improve this in my other PR but having some issues with tests failing.