Try all pending allocations
We can have outstanding allocations for different ranges owned by different peers, so we should not short circuit after the first space request.
This commit is contained in:
1 parent
6a9f9f66dc
commit
bceabe32a2
1 file changed
+11
-17
+11
-17
@@ -140,29 +140,23 @@ func (alloc *Allocator) cancelOpsFor(ops *[]operation, ident string) bool {
|
|||||||
return found
|
return found
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try all pending operations
|
// Try all operations in a queue
|
||||||
func (alloc *Allocator) tryPendingOps() {
|
func (alloc *Allocator) tryOps(ops *[]operation) {
|
||||||
// The slightly different semantics requires us to operate on 'claims' and
|
for i := 0; i < len(*ops); {
|
||||||
// 'allocates' separately:
|
op := (*ops)[i]
|
||||||
// Claims must be tried before Allocates
|
|
||||||
for i := 0; i < len(alloc.pendingClaims); {
|
|
||||||
op := alloc.pendingClaims[i]
|
|
||||||
if !op.Try(alloc) {
|
if !op.Try(alloc) {
|
||||||
i++
|
i++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
alloc.pendingClaims = append(alloc.pendingClaims[:i], alloc.pendingClaims[i+1:]...)
|
*ops = append((*ops)[:i], (*ops)[i+1:]...)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// When the first Allocate fails, bail - no need to
|
// Try all pending operations
|
||||||
// send too many begs for space.
|
func (alloc *Allocator) tryPendingOps() {
|
||||||
for i := 0; i < len(alloc.pendingAllocates); {
|
// Process existing claims before servicing new allocations
|
||||||
op := alloc.pendingAllocates[i]
|
alloc.tryOps(&alloc.pendingClaims)
|
||||||
if !op.Try(alloc) {
|
alloc.tryOps(&alloc.pendingAllocates)
|
||||||
break
|
|
||||||
}
|
|
||||||
alloc.pendingAllocates = append(alloc.pendingAllocates[:i], alloc.pendingAllocates[i+1:]...)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (alloc *Allocator) spaceRequestDenied(sender mesh.PeerName, r address.Range) {
|
func (alloc *Allocator) spaceRequestDenied(sender mesh.PeerName, r address.Range) {
|
||||||
|
|||||||
Reference in new issue
Block a user