fix: mutex lock to avoid concurrent map writes (#2796)

This commit is contained in:
Vishal Sharma 2023-05-31 11:27:09 +05:30 committed by GitHub
parent bc5862646d
commit 26a806a7fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -308,9 +308,13 @@ func (a *Telemetry) SendEvent(event string, data map[string]interface{}, opts ..
}
if rateLimitFlag {
if a.rateLimits[event] < RATE_LIMIT_VALUE {
telemetry.mutex.Lock()
limit := a.rateLimits[event]
if limit < RATE_LIMIT_VALUE {
a.rateLimits[event] += 1
telemetry.mutex.Unlock()
} else {
telemetry.mutex.Unlock()
return
}
}