forked from quic-go/quic-go
remove queued StreamFrames when a Stream is closed with an error
fixes #149
This commit is contained in:
13
session.go
13
session.go
@@ -364,7 +364,7 @@ func (s *Session) handleRstStreamFrame(frame *frames.RstStreamFrame) error {
|
||||
if !streamExists || str == nil {
|
||||
return errRstStreamOnInvalidStream
|
||||
}
|
||||
str.RegisterError(fmt.Errorf("RST_STREAM received with code %d", frame.ErrorCode))
|
||||
s.closeStreamWithError(str, fmt.Errorf("RST_STREAM received with code %d", frame.ErrorCode))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -409,14 +409,19 @@ func (s *Session) closeImpl(e error, remoteClose bool) error {
|
||||
func (s *Session) closeStreamsWithError(err error) {
|
||||
s.streamsMutex.Lock()
|
||||
defer s.streamsMutex.Unlock()
|
||||
for _, s := range s.streams {
|
||||
if s == nil {
|
||||
for _, str := range s.streams {
|
||||
if str == nil {
|
||||
continue
|
||||
}
|
||||
s.RegisterError(err)
|
||||
s.closeStreamWithError(str, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Session) closeStreamWithError(str *stream, err error) {
|
||||
s.streamFrameQueue.RemoveStream(str.StreamID())
|
||||
str.RegisterError(err)
|
||||
}
|
||||
|
||||
// TODO: try sending more than one packet
|
||||
func (s *Session) maybeSendPacket() error {
|
||||
if !s.smallPacketDelayedOccurranceTime.IsZero() && time.Now().Sub(s.smallPacketDelayedOccurranceTime) > protocol.SmallPacketSendDelay {
|
||||
|
||||
Reference in New Issue
Block a user