summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@chef.io>2019-10-12 10:01:49 -0700
committerGitHub <noreply@github.com>2019-10-12 10:01:49 -0700
commitede12bee645569f9151b1316384859fdc3746280 (patch)
treebfe87130229059e4f5a82eeb62f7f503bb86dd6f
parentb305afd1472ce042cdb243a6655387ddb5f8be45 (diff)
parent9feae3d413eaf343a201fdb39a75f5001e1783a3 (diff)
downloadchef-ede12bee645569f9151b1316384859fdc3746280.tar.gz
Event dispatcher thread local storage (#8950)
Event dispatcher thread local storage
-rw-r--r--lib/chef/event_dispatch/dispatcher.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/chef/event_dispatch/dispatcher.rb b/lib/chef/event_dispatch/dispatcher.rb
index 2fee4bcd0b..b4a2d7879b 100644
--- a/lib/chef/event_dispatch/dispatcher.rb
+++ b/lib/chef/event_dispatch/dispatcher.rb
@@ -10,11 +10,18 @@ class Chef
class Dispatcher < Base
attr_reader :subscribers
- attr_reader :event_list
def initialize(*subscribers)
@subscribers = subscribers
- @event_list = []
+ end
+
+ # Since the cookbook synchronizer will call this object from threads, we
+ # have to deal with concurrent access to this object. Since we don't want
+ # threads to handle events from other threads, we just use thread local
+ # storage.
+ #
+ def event_list
+ Thread.current[:chef_client_event_list] ||= []
end
# Add a new subscriber to the list of registered subscribers