hashicorp / yamux

Golang connection multiplexing library
Mozilla Public License 2.0
2.22k stars 234 forks source link

let ErrTimeout temporary #121

Open fatedier opened 1 year ago

fatedier commented 1 year ago

ErrTimeout should be temporary, just like the standard packages in Golang.

// Read header, payload.
if err := c.readFromUntil(c.conn, recordHeaderLen); err != nil {
    // RFC 8446, Section 6.1 suggests that EOF without an alertCloseNotify
    // is an error, but popular web sites seem to do this, so we accept it
    // if and only if at the record boundary.
    if err == io.ErrUnexpectedEOF && c.rawInput.Len() == 0 {
        err = io.EOF
    }
    if e, ok := err.(net.Error); !ok || !e.Temporary() {
        c.in.setErrorLocked(err)
    }
    return err
}

When we use tls.Conn to wrap yamux.Stream, if a read deadline occurs, it will cause subsequent read operations to fail continuously because e.Temporary() returns false, indicating a permanent error.

@jefferai @dadgar PTAL