Persist ring after updates caused by reportFreeSpace()
This commit is contained in:
1 parent
6062627582
commit
e2bee6e8c6
2 files changed
+7
-3
No files matched your search
+3
-1
@@ -898,7 +898,9 @@ func (alloc *Allocator) reportFreeSpace() {
|
||||
for _, r := range ranges {
|
||||
freespace[r.Start] = alloc.space.NumFreeAddressesInRange(r)
|
||||
}
|
||||
alloc.ring.ReportFree(freespace)
|
||||
if alloc.ring.ReportFree(freespace) {
|
||||
alloc.persistRing()
|
||||
}
|
||||
}
|
||||
|
||||
// Persistent data
|
||||
|
||||
+4
-2
@@ -417,8 +417,8 @@ func (r *Ring) String() string {
|
||||
|
||||
// ReportFree is used by the allocator to tell the ring how many free
|
||||
// ips are in a given range, so that ChoosePeersToAskForSpace can make
|
||||
// more intelligent decisions.
|
||||
func (r *Ring) ReportFree(freespace map[address.Address]address.Count) {
|
||||
// more intelligent decisions. Returns true if any changes made.
|
||||
func (r *Ring) ReportFree(freespace map[address.Address]address.Count) (updated bool) {
|
||||
r.assertInvariants()
|
||||
defer r.assertInvariants()
|
||||
defer r.updateExportedVariables()
|
||||
@@ -456,7 +456,9 @@ func (r *Ring) ReportFree(freespace map[address.Address]address.Count) {
|
||||
|
||||
entries[i].Free = free
|
||||
entries[i].Version++
|
||||
updated = true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type weightedPeer struct {
|
||||
|
||||
Reference in new issue
Block a user