Skip to content

Commit

Permalink
fix: deadlock caused by rwMutex in limiter mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolIceV committed Sep 15, 2022
1 parent 48a0733 commit a0503c6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion filter/adaptivesvc/limiter_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ func (m *limiterMapper) newAndSetMethodLimiter(url *common.URL, methodName strin
ok bool
)
m.rwMutex.Lock()
defer m.rwMutex.Unlock()

if l, ok = limiterMapperSingleton.mapper[key]; ok {
return l, nil
}
Expand All @@ -68,7 +70,6 @@ func (m *limiterMapper) newAndSetMethodLimiter(url *common.URL, methodName strin
return nil, ErrLimiterTypeNotFound
}
limiterMapperSingleton.mapper[key] = l
m.rwMutex.Unlock()
return l, nil
}

Expand Down

0 comments on commit a0503c6

Please sign in to comment.