summary refs log tree commit
diff options
context:
space:
mode:
authorKouhei Sutou <kou@clear-code.com>2016-01-25 11:17:55 +0900
committerAaron Patterson <aaron.patterson@gmail.com>2016-11-10 14:32:58 -0500
commitf51172d35991d51b32e31ed1487e2489293d0c77 (patch)
tree12c60db2122ccef2ec14b99ada7910cfa92c3318
parent8c31cef5a0e3bd4fb6b711a1fe0dca8385a3db5d (diff)
downloadrack-f51172d35991d51b32e31ed1487e2489293d0c77.tar.gz
Use Mutex instead of Thread.exclusive for reloader
Because Thread.exclusive is deprecated since Ruby 2.3.0:

  * https://github.com/ruby/ruby/blob/v2_3_0/ChangeLog#L2398-L2400
  * https://github.com/ruby/ruby/blob/v2_3_0/prelude.rb#L11
-rw-r--r--lib/rack/reloader.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/rack/reloader.rb b/lib/rack/reloader.rb
index 5f643592..296dd6a1 100644
--- a/lib/rack/reloader.rb
+++ b/lib/rack/reloader.rb
@@ -26,6 +26,7 @@ module Rack
       @last = (Time.now - cooldown)
       @cache = {}
       @mtimes = {}
+      @reload_mutex = Mutex.new
 
       extend backend
     end
@@ -33,7 +34,7 @@ module Rack
     def call(env)
       if @cooldown and Time.now > @last + @cooldown
         if Thread.list.size > 1
-          Thread.exclusive{ reload! }
+          @reload_mutex.synchronize{ reload! }
         else
           reload!
         end