diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2019-05-23 17:49:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-23 17:49:59 -0400 |
commit | 8f5b271d031d8af2046470c34638a5c1e24f9243 (patch) | |
tree | eae91acbd9847b28fd91bfaa5dd4c5da2addf86c | |
parent | c968586c2162abbca90b6feb97a9956f9c179c48 (diff) | |
parent | be34af0c531c840f1f8a36e72f8d315a0ca74f3d (diff) | |
download | rails-8f5b271d031d8af2046470c34638a5c1e24f9243.tar.gz rails-8f5b271d031d8af2046470c34638a5c1e24f9243.tar.bz2 rails-8f5b271d031d8af2046470c34638a5c1e24f9243.zip |
Merge pull request #36323 from jhawthorn/cache_expiry_mutex
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 |