Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for web transports #191

Merged
merged 8 commits into from
Jan 18, 2024
Prev Previous commit
Next Next commit
fix: only read/write error set stream to nil
sruehl committed Jan 8, 2024
commit 4a9ea0435ae73d9b775ecb9ddb4fd226cb31b606
13 changes: 11 additions & 2 deletions webtransportsconnection.go
Original file line number Diff line number Diff line change
@@ -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
}
@@ -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
}
@@ -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()
}