Skip to content
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

Properly handle io.EOF error conditions when reading #554

Merged
merged 1 commit into from
Aug 12, 2023

Commits on Aug 9, 2023

  1. Properly handle io.EOF error conditions when reading

    Previously, the Server.Serve method would never return nil,
    because the infinite for-loop handling request packets would
    only break if reading a packet reported an error.
    A common termination condition is when the underlying connection
    is closed and recvPacket returns io.EOF.
    In which case Serve should ignore io.EOF and
    treat it as a normal shutdown.
    
    However, this means that recvPacket must correctly handle io.EOF
    such that it never reports io.EOF if a packet is partially read.
    There are two calls to io.ReadFull in recvPacket.
    The first call correctly forwards an io.EOF error
    if no additional bytes of the next packet are read.
    However, the second call incorrectly forwards io.EOF
    when no bytes of the payload could be read.
    This is incorrect since we already read the length and
    should convert the io.EOF into an io.ErrUnexpectedEOF.
    dsnet committed Aug 9, 2023
    Configuration menu
    Copy the full SHA
    e9377c8 View commit details
    Browse the repository at this point in the history