Use read lock for reconciler#getHandlers

k3s-v1.15.3
Ted Yu 2019-05-31 10:39:10 -07:00 committed by Ted Yu
parent 82bfa667ed
commit ff83754a6b
3 changed files with 4 additions and 8 deletions

View File

@ -100,9 +100,7 @@ func (asw *actualStateOfWorld) RemovePlugin(socketPath string) {
asw.Lock()
defer asw.Unlock()
if _, ok := asw.socketFileToInfo[socketPath]; ok {
delete(asw.socketFileToInfo, socketPath)
}
delete(asw.socketFileToInfo, socketPath)
}
func (asw *actualStateOfWorld) GetRegisteredPlugins() []PluginInfo {

View File

@ -147,9 +147,7 @@ func (dsw *desiredStateOfWorld) RemovePlugin(socketPath string) {
dsw.Lock()
defer dsw.Unlock()
if _, ok := dsw.socketFileToInfo[socketPath]; ok {
delete(dsw.socketFileToInfo, socketPath)
}
delete(dsw.socketFileToInfo, socketPath)
}
func (dsw *desiredStateOfWorld) GetPluginsToRegister() []PluginInfo {

View File

@ -97,8 +97,8 @@ func (rc *reconciler) AddHandler(pluginType string, pluginHandler cache.PluginHa
}
func (rc *reconciler) getHandlers() map[string]cache.PluginHandler {
rc.Lock()
defer rc.Unlock()
rc.RLock()
defer rc.RUnlock()
return rc.handlers
}