From 1c1b3248c087c6316724e0a3c10f056d5fb4766e Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sun, 9 Apr 2017 23:00:29 +0000 Subject: [PATCH] Make sure we have a ring before calling tryOps() because otherwise the pending ops can be modified from inside Try() --- ipam/allocator.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ipam/allocator.go b/ipam/allocator.go index 8f1a699f..b17592a0 100644 --- a/ipam/allocator.go +++ b/ipam/allocator.go @@ -265,6 +265,10 @@ func (alloc *Allocator) tryPendingOps() { alloc.tryOps(&alloc.pendingAllocates) } +func (alloc *Allocator) havePendingOps() bool { + return len(alloc.pendingPrimes)+len(alloc.pendingClaims)+len(alloc.pendingAllocates) > 0 +} + func (alloc *Allocator) spaceRequestDenied(sender mesh.PeerName, r address.Range) { for i := 0; i < len(alloc.pendingClaims); { claim := alloc.pendingClaims[i].(*claim) @@ -696,8 +700,12 @@ func (alloc *Allocator) actorLoop(actionChan <-chan func(), stopChan <-chan stru // Retry things in case messages got lost between here and recipients if alloc.awaitingConsensus { alloc.propose() - } else { - alloc.tryPendingOps() + } else if alloc.havePendingOps() { + if alloc.ring.Empty() { + alloc.establishRing() + } else { + alloc.tryPendingOps() + } } alloc.removeDeadContainers() }