diff options
author | John Hawthorn <john@hawthorn.email> | 2019-05-21 19:39:44 -0700 |
---|---|---|
committer | John Hawthorn <john@hawthorn.email> | 2019-05-21 19:46:42 -0700 |
commit | be34af0c531c840f1f8a36e72f8d315a0ca74f3d (patch) | |
tree | 0e820c084d93dc67a3a3006e078334dd54ff31ae | |
parent | 95e952626d30ef0fc9ea9df46bf4c3bcaf20415a (diff) | |
download | rails-be34af0c531c840f1f8a36e72f8d315a0ca74f3d.tar.gz rails-be34af0c531c840f1f8a36e72f8d315a0ca74f3d.tar.bz2 rails-be34af0c531c840f1f8a36e72f8d315a0ca74f3d.zip |
Wrap actionview cache expiry in a mutex
-rw-r--r-- | actionview/lib/action_view/cache_expiry.rb | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/actionview/lib/action_view/cache_expiry.rb b/actionview/lib/action_view/cache_expiry.rb index 820afc093d..3d8ffeaefb 100644 --- a/actionview/lib/action_view/cache_expiry.rb +++ b/actionview/lib/action_view/cache_expiry.rb @@ -16,18 +16,21 @@ module ActionView @watched_dirs = nil @watcher_class = watcher @watcher = nil + @mutex = Mutex.new end def clear_cache_if_necessary - watched_dirs = dirs_to_watch - if watched_dirs != @watched_dirs - @watched_dirs = watched_dirs - @watcher = @watcher_class.new([], watched_dirs) do - clear_cache + @mutex.synchronize do + watched_dirs = dirs_to_watch + if watched_dirs != @watched_dirs + @watched_dirs = watched_dirs + @watcher = @watcher_class.new([], watched_dirs) do + clear_cache + end + @watcher.execute + else + @watcher.execute_if_updated end - @watcher.execute - else - @watcher.execute_if_updated end end |