Skip to content

Commit

Permalink
Add locks for plugin config to avoid possible race condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pushpalanka committed Jul 4, 2024
1 parent b9302f3 commit 35ab4b2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugins/bundle/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ func (p *Plugin) Reconfigure(ctx context.Context, config interface{}) {
// Look for any bundles that have had their config changed, are new, or have been removed
newConfig := config.(*Config)
newBundles, updatedBundles, deletedBundles := p.configDelta(newConfig)

p.mtx.Lock()
p.config = *newConfig
p.mtx.Unlock()

if len(updatedBundles) == 0 && len(newBundles) == 0 && len(deletedBundles) == 0 {
// no relevant config changes
Expand Down Expand Up @@ -643,6 +646,8 @@ func (p *Plugin) activate(ctx context.Context, name string, b *bundle.Bundle) er
}

func (p *Plugin) persistBundle(name string) bool {
p.mtx.Lock()
defer p.mtx.Unlock()
bundleSrc := p.config.Bundles[name]

if bundleSrc == nil {
Expand Down

0 comments on commit 35ab4b2

Please sign in to comment.