From 3b3cd277f827e52bce5f04072c07a3a23386fee6 Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Tue, 15 Oct 2019 22:06:11 +0100 Subject: [PATCH] Fix stream not closing --- internal/multiplex/session.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/multiplex/session.go b/internal/multiplex/session.go index 703a465..bdda544 100644 --- a/internal/multiplex/session.go +++ b/internal/multiplex/session.go @@ -136,16 +136,15 @@ func (sesh *Session) Accept() (net.Conn, error) { } func (sesh *Session) closeStream(s *Stream, active bool) error { + if s.isClosed() { + return errors.New("Already Closed") + } atomic.StoreUint32(&s.closed, 1) _ = s.recvBuf.Close() // both datagramBuffer and streamBuffer won't return err on Close() if active { s.writingM.Lock() defer s.writingM.Unlock() - if s.isClosed() { - return errors.New("Already Closed") - } - // Notify remote that this stream is closed pad := genRandomPadding() f := &Frame{