From 0b1a4b90818f257b3b47fdb98a5a15fbd307b552 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 5 Apr 2023 16:43:02 +0200 Subject: [PATCH] user: fix upstream connections closed after 1 minute Fixes: ac16729f93f6 ("user: fix dup upstream connections due to race") --- user.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/user.go b/user.go index 90c0520..771a4ad 100644 --- a/user.go +++ b/user.go @@ -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() }()