TUN-6385: Don't share err between acceptStream loop and per-stream goroutines
This commit is contained in:
parent
69b28e358c
commit
e8407848ec
|
@ -122,6 +122,11 @@ func (q *QUICConnection) serveControlStream(ctx context.Context, controlStream q
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close closes the session with no errors specified.
|
||||||
|
func (q *QUICConnection) Close() {
|
||||||
|
q.session.CloseWithError(0, "")
|
||||||
|
}
|
||||||
|
|
||||||
func (q *QUICConnection) acceptStream(ctx context.Context) error {
|
func (q *QUICConnection) acceptStream(ctx context.Context) error {
|
||||||
defer q.Close()
|
defer q.Close()
|
||||||
for {
|
for {
|
||||||
|
@ -133,20 +138,17 @@ func (q *QUICConnection) acceptStream(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
return fmt.Errorf("failed to accept QUIC stream: %w", err)
|
return fmt.Errorf("failed to accept QUIC stream: %w", err)
|
||||||
}
|
}
|
||||||
go func() {
|
go q.runStream(quicStream)
|
||||||
stream := quicpogs.NewSafeStreamCloser(quicStream)
|
|
||||||
defer stream.Close()
|
|
||||||
|
|
||||||
if err = q.handleStream(stream); err != nil {
|
|
||||||
q.logger.Err(err).Msg("Failed to handle QUIC stream")
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close closes the session with no errors specified.
|
func (q *QUICConnection) runStream(quicStream quic.Stream) {
|
||||||
func (q *QUICConnection) Close() {
|
stream := quicpogs.NewSafeStreamCloser(quicStream)
|
||||||
q.session.CloseWithError(0, "")
|
defer stream.Close()
|
||||||
|
|
||||||
|
if err := q.handleStream(stream); err != nil {
|
||||||
|
q.logger.Err(err).Msg("Failed to handle QUIC stream")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *QUICConnection) handleStream(stream io.ReadWriteCloser) error {
|
func (q *QUICConnection) handleStream(stream io.ReadWriteCloser) error {
|
||||||
|
|
Loading…
Reference in New Issue