fix(registry): data race registry update (#156)
SonarQube Scan / SonarQube Trigger (push) Successful in 4m45s
SonarQube Scan / SonarQube Trigger (push) Successful in 4m45s
Concurrent map read and map write crashing the whole server Bug fixes: - Fix data race in registry.Update Reviewed-on: #156 Co-authored-by: Bagas <bagas@fossy.my.id> Co-committed-by: Bagas <bagas@fossy.my.id>
This commit was merged in pull request #156.
This commit is contained in:
@@ -94,13 +94,13 @@ func (r *registry) Update(user string, oldKey, newKey Key) error {
|
|||||||
return ErrInvalidSlug
|
return ErrInvalidSlug
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.mu.Lock()
|
||||||
|
defer r.mu.Unlock()
|
||||||
|
|
||||||
if _, exists := r.slugIndex[newKey]; exists && newKey != oldKey {
|
if _, exists := r.slugIndex[newKey]; exists && newKey != oldKey {
|
||||||
return ErrSlugInUse
|
return ErrSlugInUse
|
||||||
}
|
}
|
||||||
|
|
||||||
r.mu.Lock()
|
|
||||||
defer r.mu.Unlock()
|
|
||||||
|
|
||||||
client, ok := r.byUser[user][oldKey]
|
client, ok := r.byUser[user][oldKey]
|
||||||
if !ok {
|
if !ok {
|
||||||
return ErrSessionNotFound
|
return ErrSessionNotFound
|
||||||
|
|||||||
Reference in New Issue
Block a user