mirror of https://github.com/cbeuw/Cloak
Fix stream not closing
This commit is contained in:
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…
Reference in New Issue