Stop repetitive closing

This commit is contained in:
Qian Wang 2018-12-29 00:02:59 +00:00
parent 4b6ab1b4d5
commit e31aef3030
1 changed files with 6 additions and 0 deletions

View File

@ -120,6 +120,12 @@ func (stream *Stream) passiveClose() {
func (stream *Stream) Close() error {
stream.writingM.Lock()
select {
case <-stream.die:
stream.writingM.Unlock()
return errors.New("Already Closed")
default:
}
stream.heliumMask.Do(func() { close(stream.die) })
// Notify remote that this stream is closed