From 3597af789ece03cf1cf0ba86513685bf5ab1b1dd Mon Sep 17 00:00:00 2001 From: jiuker <2818723467@qq.com> Date: Wed, 16 Nov 2022 19:04:36 +0800 Subject: [PATCH] allow resultCh to be closed() after clusterMetaHealthInfo() (#16073) --- cmd/admin-handlers.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index e3a218ea6..40bf3a017 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -2613,7 +2613,10 @@ func getClusterMetaInfo(ctx context.Context) []byte { defer cancel() resultCh := make(chan madmin.ClusterRegistrationInfo) + go func() { + defer close(resultCh) + ci := madmin.ClusterRegistrationInfo{} ci.Info.NoOfServerPools = len(globalEndpoints) ci.Info.NoOfServers = len(globalEndpoints.Hostnames()) @@ -2635,7 +2638,12 @@ func getClusterMetaInfo(ctx context.Context) []byte { ci.DeploymentID = globalDeploymentID ci.ClusterName = fmt.Sprintf("%d-servers-%d-disks-%s", ci.Info.NoOfServers, ci.Info.NoOfDrives, ci.Info.MinioVersion) - resultCh <- ci + + select { + case resultCh <- ci: + case <-ctx.Done(): + return + } }() select {