Skip to content

Commit

Permalink
fix: only read/write error set stream to nil
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Jan 4, 2024
1 parent a90b8a0 commit a4070cd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions webtransportsconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (w *webTransportsConnection) Write(p []byte) (n int, err error) {
func() {})
if err != nil {
err = fmt.Errorf("%T: %w", w, err)
_ = w.stream.Close()
_ = w.closeStream()
}
return n, err
}
Expand All @@ -53,7 +53,7 @@ func (w *webTransportsConnection) Read(p []byte) (n int, err error) {
func() {})
if err != nil {
err = fmt.Errorf("%T: %w", w, err)
_ = w.stream.Close()
_ = w.closeStream()
}
return n, err
}
Expand All @@ -66,3 +66,12 @@ func (w *webTransportsConnection) syncStream() (err error) {
}
return
}

func (w *webTransportsConnection) closeStream() (err error) {
w.Lock()
defer w.Unlock()
if w.stream == nil {
return nil
}
return w.stream.Close()
}

0 comments on commit a4070cd

Please sign in to comment.