From 6c941122eb53896ef536686faf7836cd05ec7d51 Mon Sep 17 00:00:00 2001 From: Poorna Krishnamoorthy Date: Fri, 17 Sep 2021 23:05:38 -0400 Subject: [PATCH] cancel active goroutine when remote target is edited (#13243) --- cmd/bucket-targets.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/bucket-targets.go b/cmd/bucket-targets.go index 8a4e66e93..8699c1add 100644 --- a/cmd/bucket-targets.go +++ b/cmd/bucket-targets.go @@ -156,6 +156,10 @@ func (sys *BucketTargetSys) SetTarget(ctx context.Context, bucket string, tgt *m if !found && !update { newtgts = append(newtgts, *tgt) } + // cancel health check for previous target client to avoid leak. + if prevClnt, ok := sys.arnRemotesMap[tgt.Arn]; ok && prevClnt.healthCancelFn != nil { + prevClnt.healthCancelFn() + } sys.targetsMap[bucket] = newtgts sys.arnRemotesMap[tgt.Arn] = clnt