fix: don't fail reads when the close_notify reply cannot be sent#73
Open
ArniDagur wants to merge 1 commit into
Open
fix: don't fail reads when the close_notify reply cannot be sent#73ArniDagur wants to merge 1 commit into
close_notify reply cannot be sent#73ArniDagur wants to merge 1 commit into
Conversation
If the peer stops reading our data and then closes the connection, a read on our side returns an error instead of EOF. Namely: - On receiving the peer's close_notify (or a fatal alert), we reply with a close_notify of our own, directly via sendmsg. - Our send buffer is full, so the sendmsg fails with EAGAIN, and the read returns Err(WouldBlock). The reply is best-effort: the session is over whether or not we manage to send it, and the next read would return EOF anyway (read_closed is already set). Log the failure and return EOF.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This bug was discovered while creating a reproducer for #72
If the peer stops reading our data and then closes the connection, a read on our side returns an error instead of EOF. Namely:
close_notifyof our own.sendmsgfails withEAGAIN, and the read returnsErr(WouldBlock).The reply is best-effort: the session is over whether or not we manage to send it, and the next read would return EOF anyway (
read_closedis already set). Log the failure and return EOF.