Skip to content

Commit

Permalink
fix:修复map并发读写问题 (#1041)
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun authored Mar 25, 2023
1 parent 741398f commit 404e3ab
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugin/statis/base/apicall.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 404e3ab

Please sign in to comment.