mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 23:03:10 -06:00
Take write lock for rate limit map
This commit is contained in:
parent
4a7fb9c045
commit
d52362a106
|
|
@ -73,8 +73,13 @@ func (l *rateLimits) rateLimit(req *http.Request) *util.JSONResponse {
|
|||
// let's create one.
|
||||
rateLimit, ok := l.limits[caller]
|
||||
if !ok {
|
||||
l.limits[caller] = make(chan struct{}, l.requestThreshold)
|
||||
rateLimit = l.limits[caller]
|
||||
rateLimit = make(chan struct{}, l.requestThreshold)
|
||||
|
||||
l.limitsMutex.RUnlock()
|
||||
l.limitsMutex.Lock()
|
||||
l.limits[caller] = rateLimit
|
||||
l.limitsMutex.Unlock()
|
||||
l.limitsMutex.RLock()
|
||||
}
|
||||
|
||||
// Check if the user has got free resource slots for this request.
|
||||
|
|
|
|||
Loading…
Reference in a new issue