Skip to content

Commit

Permalink
refactor:fix config notify watch client may cause client hangup (#1348)
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun authored Apr 16, 2024
1 parent eb589ff commit cea21e9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions config/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ func (wc *watchCenter) RemoveAllWatcher(clientId string) {
}
watchers.Remove(clientId)
}
wc.clients.Delete(clientId)
}

// RemoveWatcher 删除订阅者
Expand Down Expand Up @@ -345,11 +346,10 @@ func (wc *watchCenter) notifyToWatchers(publishConfigFile *model.SimpleConfigFil
if watchCtx.ShouldNotify(publishConfigFile) {
watchCtx.Reply(response)
notifyCnt++
}
// 只能用一次,通知完就要立马清理掉这个 WatchContext
if watchCtx.IsOnce() {
wc.clients.Delete(clientId)
wc.RemoveAllWatcher(watchCtx.ClientID())
// 只能用一次,通知完就要立马清理掉这个 WatchContext
if watchCtx.IsOnce() {
wc.RemoveAllWatcher(watchCtx.ClientID())
}
}
})

Expand Down

0 comments on commit cea21e9

Please sign in to comment.