From 844af9fa7c18a0ee3316d6cf1289b144d48d84d7 Mon Sep 17 00:00:00 2001 From: schneems Date: Thu, 9 Jun 2016 16:42:20 -0500 Subject: Lock the whole boot step, get rid of unneeded hash --- .../lib/active_support/evented_file_update_checker.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/evented_file_update_checker.rb b/activesupport/lib/active_support/evented_file_update_checker.rb index 063839f5af..a2dcf31132 100644 --- a/activesupport/lib/active_support/evented_file_update_checker.rb +++ b/activesupport/lib/active_support/evented_file_update_checker.rb @@ -43,8 +43,8 @@ module ActiveSupport @block = block @updated = Concurrent::AtomicBoolean.new(false) @lcsp = @ph.longest_common_subpath(@dirs.keys) - @pid_hash = Concurrent::Hash.new - @parent_pid = Process.pid + @pid = Process.pid + @boot_mutex = Mutex.new if (@dtw = directories_to_watch).any? # Loading listen triggers warnings. These are originated by a legit @@ -62,7 +62,13 @@ module ActiveSupport end def updated? - boot! unless @pid_hash[Process.pid] + @boot_mutex.synchronize do + if @pid != Process.pid + boot! + @pid = Process.pid + @updated.make_true + end + end @updated.true? end @@ -82,8 +88,6 @@ module ActiveSupport private def boot! Listen.to(*@dtw, &method(:changed)).start - @pid_hash[Process.pid] = true - @updated.make_true if @parent_pid != Process.pid end def changed(modified, added, removed) -- cgit v1.2.3