Fix stream not closing

pull/71/head
Andy Wang 5 years ago
parent 67159abcf4
commit 3b3cd277f8

@ -136,16 +136,15 @@ 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 s.isClosed() {
return errors.New("Already Closed")
}
atomic.StoreUint32(&s.closed, 1) atomic.StoreUint32(&s.closed, 1)
_ = 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()
if active { if active {
s.writingM.Lock() s.writingM.Lock()
defer s.writingM.Unlock() defer s.writingM.Unlock()
if s.isClosed() {
return errors.New("Already Closed")
}
// Notify remote that this stream is closed // Notify remote that this stream is closed
pad := genRandomPadding() pad := genRandomPadding()
f := &Frame{ f := &Frame{

Loading…
Cancel
Save