diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-10-19 14:24:57 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-10-19 14:24:57 -0700 |
| commit | 410b818aa7d99bcc830d0dbafac9c7298a2afceb (patch) | |
| tree | b65af8b6c611892daa431cab94c6bfebbbba22ff | |
| parent | 69f0da5d73b6f681b2313e3230a39e254693f453 (diff) | |
| download | seaweedfs-410b818aa7d99bcc830d0dbafac9c7298a2afceb.tar.xz seaweedfs-410b818aa7d99bcc830d0dbafac9c7298a2afceb.zip | |
master: avoid timer leakage
| -rw-r--r-- | weed/topology/topology_vacuum.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/weed/topology/topology_vacuum.go b/weed/topology/topology_vacuum.go index 4f3d69627..7bf55d131 100644 --- a/weed/topology/topology_vacuum.go +++ b/weed/topology/topology_vacuum.go @@ -42,13 +42,17 @@ func batchVacuumVolumeCheck(grpcDialOption grpc.DialOption, vl *VolumeLayout, vi }(index, dn.Url(), vid) } vacuumLocationList := NewVolumeLocationList() + + waitTimeout := time.NewTimer(30 * time.Minute) + defer waitTimeout.Stop() + for range locationlist.list { select { case index := <-ch: if index != -1 { vacuumLocationList.list = append(vacuumLocationList.list, locationlist.list[index]) } - case <-time.After(30 * time.Minute): + case <-waitTimeout.C: return vacuumLocationList, false } } @@ -81,11 +85,15 @@ func batchVacuumVolumeCompact(grpcDialOption grpc.DialOption, vl *VolumeLayout, }(index, dn.Url(), vid) } isVacuumSuccess := true + + waitTimeout := time.NewTimer(30 * time.Minute) + defer waitTimeout.Stop() + for range locationlist.list { select { case canCommit := <-ch: isVacuumSuccess = isVacuumSuccess && canCommit - case <-time.After(30 * time.Minute): + case <-waitTimeout.C: return false } } |
