mirror of https://github.com/cbeuw/Cloak
Log repeat stream closing on Debug level
This commit is contained in:
parent
5baac79e56
commit
1c8903f249
|
|
@ -20,6 +20,7 @@ const (
|
||||||
|
|
||||||
var ErrBrokenSession = errors.New("broken session")
|
var ErrBrokenSession = errors.New("broken session")
|
||||||
var errRepeatSessionClosing = errors.New("trying to close a closed session")
|
var errRepeatSessionClosing = errors.New("trying to close a closed session")
|
||||||
|
var errRepeatStreamClosing = errors.New("trying to close a closed stream")
|
||||||
|
|
||||||
type switchboardStrategy int
|
type switchboardStrategy int
|
||||||
|
|
||||||
|
|
@ -145,7 +146,7 @@ func (sesh *Session) Accept() (net.Conn, error) {
|
||||||
|
|
||||||
func (sesh *Session) closeStream(s *Stream, active bool) error {
|
func (sesh *Session) closeStream(s *Stream, active bool) error {
|
||||||
if atomic.SwapUint32(&s.closed, 1) == 1 {
|
if atomic.SwapUint32(&s.closed, 1) == 1 {
|
||||||
return fmt.Errorf("stream %v is already closed", s.id)
|
return fmt.Errorf("closing stream %v: %w", s.id, errRepeatStreamClosing)
|
||||||
}
|
}
|
||||||
_ = s.recvBuf.Close() // both datagramBuffer and streamBuffer won't return err on Close()
|
_ = s.recvBuf.Close() // both datagramBuffer and streamBuffer won't return err on Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,12 @@ func (s *Stream) isClosed() bool { return atomic.LoadUint32(&s.closed) == 1 }
|
||||||
func (s *Stream) writeFrame(frame Frame) error {
|
func (s *Stream) writeFrame(frame Frame) error {
|
||||||
toBeClosed, err := s.recvBuf.Write(frame)
|
toBeClosed, err := s.recvBuf.Write(frame)
|
||||||
if toBeClosed {
|
if toBeClosed {
|
||||||
return s.passiveClose()
|
err = s.passiveClose()
|
||||||
|
if errors.Is(err, errRepeatStreamClosing) {
|
||||||
|
log.Debug(err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue