Skip to content

Commit bf7fbe3

Browse files
authored
Guard new leaf generation with a mutex (#166)
1 parent 851b43c commit bf7fbe3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

hammer/hammer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,10 @@ func genLeaf(n uint64, minLeafSize int) []byte {
301301
func newLeafGenerator(n uint64, minLeafSize int) func() []byte {
302302
const dupChance = 0.1
303303
nextLeaf := genLeaf(n, minLeafSize)
304+
var safe sync.Mutex
304305
return func() []byte {
306+
safe.Lock()
307+
defer safe.Unlock()
305308
if rand.Float64() <= dupChance {
306309
// This one will actually be unique, but the next iteration will
307310
// duplicate it. In future, this duplication could be randomly

0 commit comments

Comments
 (0)