functional/tester: fix racey map writes
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>release-3.4
parent
d69b7d28a0
commit
0a92ba66fa
|
@ -35,6 +35,7 @@ func (cs *compositeStresser) Stress() error {
|
|||
}
|
||||
|
||||
func (cs *compositeStresser) Pause() (ems map[string]int) {
|
||||
var emu sync.Mutex
|
||||
ems = make(map[string]int)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(len(cs.stressers))
|
||||
|
@ -43,7 +44,9 @@ func (cs *compositeStresser) Pause() (ems map[string]int) {
|
|||
defer wg.Done()
|
||||
errs := s.Pause()
|
||||
for k, v := range errs {
|
||||
emu.Lock()
|
||||
ems[k] += v
|
||||
emu.Unlock()
|
||||
}
|
||||
}(cs.stressers[i])
|
||||
}
|
||||
|
@ -52,6 +55,7 @@ func (cs *compositeStresser) Pause() (ems map[string]int) {
|
|||
}
|
||||
|
||||
func (cs *compositeStresser) Close() (ems map[string]int) {
|
||||
var emu sync.Mutex
|
||||
ems = make(map[string]int)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(len(cs.stressers))
|
||||
|
@ -60,7 +64,9 @@ func (cs *compositeStresser) Close() (ems map[string]int) {
|
|||
defer wg.Done()
|
||||
errs := s.Close()
|
||||
for k, v := range errs {
|
||||
emu.Lock()
|
||||
ems[k] += v
|
||||
emu.Unlock()
|
||||
}
|
||||
}(cs.stressers[i])
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue