From 404e3abfdb87c2c45d4f5d15deb00603dd1a89ef Mon Sep 17 00:00:00 2001 From: liaochuntao Date: Sat, 25 Mar 2023 18:47:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Dmap=E5=B9=B6=E5=8F=91?= =?UTF-8?q?=E8=AF=BB=E5=86=99=E9=97=AE=E9=A2=98=20(#1041)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/statis/base/apicall.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin/statis/base/apicall.go b/plugin/statis/base/apicall.go index 3448e0fe8..eff83f00f 100644 --- a/plugin/statis/base/apicall.go +++ b/plugin/statis/base/apicall.go @@ -104,6 +104,8 @@ func (a *ComponentStatics) run(ctx context.Context) { } func (c *ComponentStatics) add(ac *APICall) { + c.mutex.Lock() + defer c.mutex.Unlock() index := fmt.Sprintf("%v-%v", ac.Api, ac.Code) item, exist := c.statis[index] if exist { @@ -166,7 +168,10 @@ func (c *ComponentStatics) deal() { c.handler(c.t, startTime, nil) return } + + c.mutex.Lock() defer func() { + c.mutex.Unlock() passDuration := time.Since(startTime) if passDuration >= MaxLogWaitDuration { log.Warnf("[APICall]api static log duration %s, pass max %s", passDuration, MaxLogWaitDuration)