return a net.Error when opening streams

net.Error.Temporary() will be true if no stream can be opened when the
peer's stream limit is reached.
This commit is contained in:
Marten Seemann 2019-01-06 17:18:43 +07:00
parent 8ac77be934
commit a2e48e204b
7 changed files with 85 additions and 37 deletions

View file

@ -1,7 +1,9 @@
package quic
import (
"errors"
"fmt"
"net"
"github.com/lucas-clemente/quic-go/internal/flowcontrol"
"github.com/lucas-clemente/quic-go/internal/handshake"
@ -9,6 +11,16 @@ import (
"github.com/lucas-clemente/quic-go/internal/wire"
)
type streamOpenErr struct{ error }
var _ net.Error = &streamOpenErr{}
func (e streamOpenErr) Temporary() bool { return e.error == errTooManyOpenStreams }
func (streamOpenErr) Timeout() bool { return false }
// errTooManyOpenStreams is used internally by the outgoing streams maps.
var errTooManyOpenStreams = errors.New("too many open streams")
type streamsMap struct {
perspective protocol.Perspective