Fix stream not closing

This commit is contained in:
Andy Wang 2019-10-15 22:06:11 +01:00
parent 67159abcf4
commit 3b3cd277f8
1 changed files with 3 additions and 4 deletions

View File

@ -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{