Skip to content

fix: don't fail reads when the close_notify reply cannot be sent#73

Open
ArniDagur wants to merge 1 commit into
rustls:mainfrom
ArniDagur:fix-close-notify-reply-eagain
Open

fix: don't fail reads when the close_notify reply cannot be sent#73
ArniDagur wants to merge 1 commit into
rustls:mainfrom
ArniDagur:fix-close-notify-reply-eagain

Conversation

@ArniDagur

@ArniDagur ArniDagur commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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:

  • On receiving the peer's close_notify (or a fatal alert), we reply with a close_notify of our own.
  • 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant