给map添加lock

This commit is contained in:
M09Ic committed 2022-12-01 11:49:40 +08:00
1 parent 0f4529fede
commit 92c9049e1b
1 file changed
+3 -3
+3 -3
View File
@@ -217,6 +217,7 @@ type Pool struct {
base *pkg.Baseline
index *pkg.Baseline
baselines map[int]*pkg.Baseline
locker sync.Mutex
analyzeDone bool
genReq func(s string) (*ihttp.Request, error)
check func()
@@ -425,10 +426,9 @@ func (p *Pool) CompareWithExpr(exp *vm.Program, other *pkg.Baseline) bool {
func (p *Pool) addFuzzyBaseline(bl *pkg.Baseline) {
if _, ok := p.baselines[bl.Status]; !ok && IntsContains(FuzzyStatus, bl.Status) {
bl.Collect()
var lock sync.Mutex
lock.Lock()
p.locker.Lock()
p.baselines[bl.Status] = bl
lock.Unlock()
p.locker.Unlock()
logs.Log.Importantf("[baseline.%dinit] %s", bl.Status, bl.String())
}
}