Skip to content

Commit

Permalink
fix: use quic-go OpenStream instead of OpenStreamSync
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <christian@aperture.us>
  • Loading branch information
paralin committed Aug 2, 2024
1 parent f8b270f commit da57de4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/aperturerobotics/controllerbus v0.47.3 // latest
github.com/aperturerobotics/entitygraph v0.10.0 // latest
github.com/aperturerobotics/protobuf-go-lite v0.6.5 // latest
github.com/aperturerobotics/starpc v0.33.6 // latest
github.com/aperturerobotics/starpc v0.33.8-0.20240802223333-0a75ea3bcc0d // latest
github.com/aperturerobotics/util v1.25.7 // latest
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ github.com/aperturerobotics/protobuf-go-lite v0.6.5 h1:AuPPcZ7ZaJe9ZYYC4gF7/5/Xb
github.com/aperturerobotics/protobuf-go-lite v0.6.5/go.mod h1:YTbfnUj3feSULhs8VgepAHFnF3wUc0CPj4jd2axy21I=
github.com/aperturerobotics/quic-go v0.45.1-0.20240802054753-f83427ffc2c6 h1:MZNodbX53cJQ6UuSIut4FvJWstxn+8/E1TpF1ceYjy0=
github.com/aperturerobotics/quic-go v0.45.1-0.20240802054753-f83427ffc2c6/go.mod h1:X095EBMI8M7riYQRvUgegHFkEkgM2QKLvyGHyAcOw/Q=
github.com/aperturerobotics/starpc v0.33.6 h1:noc/MnmIMTek9bdEvd88QiD1p9KzEV8CUOBIoKmGgm0=
github.com/aperturerobotics/starpc v0.33.6/go.mod h1:4IYcbulEzqhPT5jKaDeL1BJPFd8WVWZ7Ugu0/348/Is=
github.com/aperturerobotics/starpc v0.33.8-0.20240802223333-0a75ea3bcc0d h1:Ea2OeCecGJtSUtNBcSAbbmRp90PHUWC2XAVYZbj1MNQ=
github.com/aperturerobotics/starpc v0.33.8-0.20240802223333-0a75ea3bcc0d/go.mod h1:U2Shid7XklzmLroUoParSrghpFhxfY/N3vlHqT4tvBE=
github.com/aperturerobotics/util v1.25.7 h1:e9fdF3W/E7IHdl7YAJC0jjuxGph7yzE3a5zZoLFJ3G0=
github.com/aperturerobotics/util v1.25.7/go.mod h1:G5ybyxaL62Rdv0K5ZGqu+D1NfqlZCLYPQhdfiYhxlAg=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
Expand Down
21 changes: 13 additions & 8 deletions transport/common/quic/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,25 @@ func (l *Link) RemoteAddr() net.Addr {

// OpenStream opens a stream on the link, with the given parameters.
func (l *Link) OpenStream(opts stream.OpenOpts) (stream.Stream, error) {
return l.sess.OpenStreamSync(l.ctx)
// return l.sess.OpenStreamSync(l.ctx)

// OpenStream returns an error if we hit the stream limit.
// it is better to return an error and backoff / know something is wrong,
// than wait forever (potentially) while we are at the cap.
return l.sess.OpenStream()
}

// AcceptStream accepts a stream from the link.
func (l *Link) AcceptStream() (stream.Stream, stream.OpenOpts, error) {
qstream, err := l.sess.AcceptStream(l.ctx)
if err != nil {
select {
case <-l.ctx.Done():
// detect link shutdown, avoid logging unnecessary errors
err = context.Canceled
default:
if l.ctx.Err() != nil {
// detect link shutdown, avoid logging unnecessary errors
if qstream != nil {
_ = qstream.Close()
}

return nil, stream.OpenOpts{}, context.Canceled
}
if err != nil {
qe, qeOk := err.(*quic.ApplicationError)
if qeOk && qe != nil {
// remote shutdown of connection normally
Expand Down

0 comments on commit da57de4

Please sign in to comment.