Skip to content

Commit 93e569f

Browse files
nmldieguesjoliveirinha
authored andcommitted
TUN-7146: Avoid data race in closing origin connection too early
1 parent 207f4e2 commit 93e569f

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

proxy/proxy.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,22 +288,14 @@ func (p *Proxy) proxyStream(
288288
return err
289289
}
290290
connectSpan.End()
291+
defer originConn.Close()
291292

292293
encodedSpans := tr.GetSpans()
293294

294295
if err := rwa.AckConnection(encodedSpans); err != nil {
295296
return err
296297
}
297298

298-
streamCtx, cancel := context.WithCancel(ctx)
299-
defer cancel()
300-
301-
go func() {
302-
// streamCtx is done if req is cancelled or if Stream returns
303-
<-streamCtx.Done()
304-
originConn.Close()
305-
}()
306-
307299
originConn.Stream(ctx, rwa, p.log)
308300
return nil
309301
}

0 commit comments

Comments
 (0)