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.
This commit is contained in:
Bryan Boreham committed 2015-06-15 16:51:27 +01:00
1 parent ec85da914a
commit d25d0810af
1 file changed
+7 -3
+7 -3
View File
@@ -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)