Skip to content

Commit 573794e

Browse files
committed
fix vu creation races and atomic ratelimit deref
1 parent 70bd176 commit 573794e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

wasp/wasp.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ func (g *Generator) runExecuteLoop() {
379379
for i := 0; i < int(vus); i++ {
380380
inst := g.vu.Clone(g)
381381
g.runVU(inst)
382+
g.currentSegmentMu.Lock()
382383
g.vus = append(g.vus, inst)
384+
g.currentSegmentMu.Unlock()
383385
}
384386
}
385387
}
@@ -508,6 +510,7 @@ func (g *Generator) processSegment() bool {
508510
if oldVUs == newVUs {
509511
return false
510512
}
513+
g.currentSegmentMu.Lock()
511514
if oldVUs > g.currentSegment.From {
512515
for i := 0; i < vusToSpawn; i++ {
513516
g.vus[i].Stop(g)
@@ -520,6 +523,7 @@ func (g *Generator) processSegment() bool {
520523
g.vus = append(g.vus, inst)
521524
}
522525
}
526+
g.currentSegmentMu.Unlock()
523527
}
524528
return false
525529
}
@@ -624,8 +628,10 @@ func (g *Generator) pacedCall() {
624628
if !g.Stats().RunStarted.Load() {
625629
return
626630
}
627-
l := *g.rl.Load()
628-
l.Take()
631+
if &g.rl == nil {
632+
return
633+
}
634+
(*g.rl.Load()).Take()
629635
if g.stats.RunPaused.Load() {
630636
return
631637
}

0 commit comments

Comments
 (0)