From d25d0810af06c8e75b87217dd69ae411b9662d86 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 15 Jun 2015 16:51:27 +0100 Subject: [PATCH] Extend the 'block' flag to block allocateAgain() otherwise we can re-insert the entry into the map after a parallel allocateAgain() has cleared the flag. And it /that/ happens in parallel with a free() then the data-structure can get out of sync. --- ipam/allocator_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ipam/allocator_test.go b/ipam/allocator_test.go index 57a66b2f..d32e9174 100644 --- a/ipam/allocator_test.go +++ b/ipam/allocator_test.go @@ -289,10 +289,10 @@ func TestAllocatorFuzz(t *testing.T) { common.InitDefaultLogging(false) const ( firstpass = 1000 - secondpass = 5000 + secondpass = 20000 nodes = 10 maxAddresses = 1000 - concurrency = 10 + concurrency = 30 cidr = "10.0.1.7/22" ) allocs, _, subnet := makeNetworkOfAllocators(nodes, cidr) @@ -398,12 +398,16 @@ func TestAllocatorFuzz(t *testing.T) { addrIndex := rand.Int31n(int32(len(addrs))) addr := addrs[addrIndex] res := state[addr] + if res.block { + stateLock.Unlock() + return + } res.block = true state[addr] = res stateLock.Unlock() alloc := allocs[res.alloc] - //common.Info.Printf("Asking for %s on allocator %d again", addr, res.alloc) + //common.Info.Printf("Asking for %s (%s) on allocator %d again", res.name, addr, res.alloc) newAddr, _ := alloc.Allocate(res.name, subnet, nil) oldAddr, _ := address.ParseIP(addr)