mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
master: avoid timer leakage
This commit is contained in:
parent
69f0da5d73
commit
410b818aa7
|
@ -42,13 +42,17 @@ func batchVacuumVolumeCheck(grpcDialOption grpc.DialOption, vl *VolumeLayout, vi
|
||||||
}(index, dn.Url(), vid)
|
}(index, dn.Url(), vid)
|
||||||
}
|
}
|
||||||
vacuumLocationList := NewVolumeLocationList()
|
vacuumLocationList := NewVolumeLocationList()
|
||||||
|
|
||||||
|
waitTimeout := time.NewTimer(30 * time.Minute)
|
||||||
|
defer waitTimeout.Stop()
|
||||||
|
|
||||||
for range locationlist.list {
|
for range locationlist.list {
|
||||||
select {
|
select {
|
||||||
case index := <-ch:
|
case index := <-ch:
|
||||||
if index != -1 {
|
if index != -1 {
|
||||||
vacuumLocationList.list = append(vacuumLocationList.list, locationlist.list[index])
|
vacuumLocationList.list = append(vacuumLocationList.list, locationlist.list[index])
|
||||||
}
|
}
|
||||||
case <-time.After(30 * time.Minute):
|
case <-waitTimeout.C:
|
||||||
return vacuumLocationList, false
|
return vacuumLocationList, false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,11 +85,15 @@ func batchVacuumVolumeCompact(grpcDialOption grpc.DialOption, vl *VolumeLayout,
|
||||||
}(index, dn.Url(), vid)
|
}(index, dn.Url(), vid)
|
||||||
}
|
}
|
||||||
isVacuumSuccess := true
|
isVacuumSuccess := true
|
||||||
|
|
||||||
|
waitTimeout := time.NewTimer(30 * time.Minute)
|
||||||
|
defer waitTimeout.Stop()
|
||||||
|
|
||||||
for range locationlist.list {
|
for range locationlist.list {
|
||||||
select {
|
select {
|
||||||
case canCommit := <-ch:
|
case canCommit := <-ch:
|
||||||
isVacuumSuccess = isVacuumSuccess && canCommit
|
isVacuumSuccess = isVacuumSuccess && canCommit
|
||||||
case <-time.After(30 * time.Minute):
|
case <-waitTimeout.C:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue