TUN-7146: Avoid data race in closing origin connection too early
This commit is contained in:
parent
207f4e2c8d
commit
93e569fa23
|
@ -288,6 +288,7 @@ func (p *Proxy) proxyStream(
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
connectSpan.End()
|
connectSpan.End()
|
||||||
|
defer originConn.Close()
|
||||||
|
|
||||||
encodedSpans := tr.GetSpans()
|
encodedSpans := tr.GetSpans()
|
||||||
|
|
||||||
|
@ -295,15 +296,6 @@ func (p *Proxy) proxyStream(
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
streamCtx, cancel := context.WithCancel(ctx)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
// streamCtx is done if req is cancelled or if Stream returns
|
|
||||||
<-streamCtx.Done()
|
|
||||||
originConn.Close()
|
|
||||||
}()
|
|
||||||
|
|
||||||
originConn.Stream(ctx, rwa, p.log)
|
originConn.Stream(ctx, rwa, p.log)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue