diff --git a/hammer/hammer.go b/hammer/hammer.go index 013fd08..31f99b8 100644 --- a/hammer/hammer.go +++ b/hammer/hammer.go @@ -301,7 +301,10 @@ func genLeaf(n uint64, minLeafSize int) []byte { func newLeafGenerator(n uint64, minLeafSize int) func() []byte { const dupChance = 0.1 nextLeaf := genLeaf(n, minLeafSize) + var safe sync.Mutex return func() []byte { + safe.Lock() + defer safe.Unlock() if rand.Float64() <= dupChance { // This one will actually be unique, but the next iteration will // duplicate it. In future, this duplication could be randomly