Add timeout for upstream connection registration

This commit is contained in:
Simon Ser 2022-04-15 09:49:19 +02:00
parent 77460dfb97
commit 9fb789ee26

View File

@ -191,6 +191,9 @@ 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)
ctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
uc, err := connectToUpstream(ctx, net) uc, err := connectToUpstream(ctx, net)
if err != nil { if err != nil {
return fmt.Errorf("failed to connect: %w", err) return fmt.Errorf("failed to connect: %w", err)