user: fix upstream connections closed after 1 minute
Fixes: ac16729f93
("user: fix dup upstream connections due to race")
This commit is contained in:
parent
8637550e68
commit
0b1a4b9081
3
user.go
3
user.go
@ -218,6 +218,7 @@ func (net *network) runConn(ctx context.Context) error {
|
|||||||
net.user.srv.metrics.upstreams.Add(1)
|
net.user.srv.metrics.upstreams.Add(1)
|
||||||
defer 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)
|
ctx, cancel := context.WithTimeout(ctx, time.Minute)
|
||||||
defer cancel()
|
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.
|
// The context is cancelled by the caller when the network is stopped.
|
||||||
go func() {
|
go func() {
|
||||||
<-ctx.Done()
|
<-done
|
||||||
uc.Close()
|
uc.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user