Fix data race for config with FileSource (#26518)

Signed-off-by: yah01 <yah2er0ne@outlook.com>
pull/26604/head
yah01 2023-08-24 09:18:24 +08:00 committed by GitHub
parent c2b53bb9fe
commit c3f5856fbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -91,6 +91,8 @@ func (fs *FileSource) Close() {
}
func (fs *FileSource) SetEventHandler(eh EventHandler) {
fs.RWMutex.Lock()
defer fs.RWMutex.Unlock()
fs.configRefresher.eh = eh
}

View File

@ -86,7 +86,7 @@ func (r *refresher) fireEvents(name string, source, target map[string]string) er
log.Warn("generating event error", zap.Error(err))
return err
}
//Generate OnEvent Callback based on the events created
// Generate OnEvent Callback based on the events created
if r.eh != nil {
for _, e := range events {
r.eh.OnEvent(e)