user: fix upstream connections closed after 1 minute

Fixes: ac16729f93 ("user: fix dup upstream connections due to race")
This commit is contained in:
Simon Ser 2023-04-05 16:43:02 +02:00
parent 8637550e68
commit 0b1a4b9081

View File

@ -218,6 +218,7 @@ func (net *network) runConn(ctx context.Context) error {
net.user.srv.metrics.upstreams.Add(1)
defer net.user.srv.metrics.upstreams.Add(-1)
done := ctx.Done()
ctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
@ -229,7 +230,7 @@ func (net *network) runConn(ctx context.Context) error {
// The context is cancelled by the caller when the network is stopped.
go func() {
<-ctx.Done()
<-done
uc.Close()
}()