Skip to content

Commit

Permalink
🐞 fix: (#740)
Browse files Browse the repository at this point in the history
Adjust lock order to address concurrency issue  Moved defer ed.mux.Unlock() after ed.mux.Lock() to ensure immediate unlocking after acquiring the lock, resolving potential concurrency issues.
  • Loading branch information
XiaoK29 authored Apr 25, 2024
1 parent 169486a commit 6f9348a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clients/naming_client/naming_cache/subscribe_callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func (ed *SubscribeCallback) IsSubscribed(serviceName, clusters string) bool {

func (ed *SubscribeCallback) AddCallbackFunc(serviceName string, clusters string, callbackFunc *func(services []model.Instance, err error)) {
key := util.GetServiceCacheKey(serviceName, clusters)
defer ed.mux.Unlock()
ed.mux.Lock()
defer ed.mux.Unlock()
var funcSlice []*func(services []model.Instance, err error)
old, ok := ed.callbackFuncMap.Get(key)
if ok {
Expand Down

0 comments on commit 6f9348a

Please sign in to comment.