aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actioncable/app/assets/javascripts/action_cable/connection.coffee1
-rw-r--r--actioncable/app/assets/javascripts/action_cable/connection_monitor.coffee1
-rw-r--r--activesupport/lib/active_support/execution_wrapper.rb21
-rw-r--r--activesupport/lib/active_support/reloader.rb4
4 files changed, 18 insertions, 9 deletions
diff --git a/actioncable/app/assets/javascripts/action_cable/connection.coffee b/actioncable/app/assets/javascripts/action_cable/connection.coffee
index e8c9ae6bd0..25793ea3d3 100644
--- a/actioncable/app/assets/javascripts/action_cable/connection.coffee
+++ b/actioncable/app/assets/javascripts/action_cable/connection.coffee
@@ -101,4 +101,5 @@ class ActionCable.Connection
disconnect: ->
return if @disconnected
@disconnected = true
+ @consumer.connectionMonitor.disconnected()
@consumer.subscriptions.notifyAll("disconnected")
diff --git a/actioncable/app/assets/javascripts/action_cable/connection_monitor.coffee b/actioncable/app/assets/javascripts/action_cable/connection_monitor.coffee
index 740e86643e..904a426644 100644
--- a/actioncable/app/assets/javascripts/action_cable/connection_monitor.coffee
+++ b/actioncable/app/assets/javascripts/action_cable/connection_monitor.coffee
@@ -18,6 +18,7 @@ class ActionCable.ConnectionMonitor
disconnected: ->
@disconnectedAt = now()
+ ActionCable.log("ConnectionMonitor disconnected")
ping: ->
@pingedAt = now()
diff --git a/activesupport/lib/active_support/execution_wrapper.rb b/activesupport/lib/active_support/execution_wrapper.rb
index e784556abf..2bd1c01d35 100644
--- a/activesupport/lib/active_support/execution_wrapper.rb
+++ b/activesupport/lib/active_support/execution_wrapper.rb
@@ -4,6 +4,10 @@ module ActiveSupport
class ExecutionWrapper
include ActiveSupport::Callbacks
+ Null = Object.new # :nodoc:
+ def Null.complete! # :nodoc:
+ end
+
define_callbacks :run
define_callbacks :complete
@@ -22,7 +26,11 @@ module ActiveSupport
#
# Where possible, prefer +wrap+.
def self.run!
- new.tap(&:run!)
+ if active?
+ Null
+ else
+ new.tap(&:run!)
+ end
end
# Perform the work in the supplied block as an execution.
@@ -43,17 +51,17 @@ module ActiveSupport
def self.inherited(other) # :nodoc:
super
- other.active = Concurrent::Hash.new(0)
+ other.active = Concurrent::Hash.new
end
- self.active = Concurrent::Hash.new(0)
+ self.active = Concurrent::Hash.new
def self.active? # :nodoc:
- @active[Thread.current] > 0
+ @active[Thread.current]
end
def run! # :nodoc:
- self.class.active[Thread.current] += 1
+ self.class.active[Thread.current] = true
run_callbacks(:run)
end
@@ -63,7 +71,8 @@ module ActiveSupport
# Where possible, prefer +wrap+.
def complete!
run_callbacks(:complete)
- self.class.active.delete Thread.current if (self.class.active[Thread.current] -= 1) == 0
+ ensure
+ self.class.active.delete Thread.current
end
end
end
diff --git a/activesupport/lib/active_support/reloader.rb b/activesupport/lib/active_support/reloader.rb
index d88fcbcf78..5d1f0e1e66 100644
--- a/activesupport/lib/active_support/reloader.rb
+++ b/activesupport/lib/active_support/reloader.rb
@@ -22,8 +22,6 @@ module ActiveSupport
# unloaded.
#
class Reloader < ExecutionWrapper
- Null = Class.new(ExecutionWrapper) # :nodoc:
-
define_callbacks :prepare
define_callbacks :class_unload
@@ -54,7 +52,7 @@ module ActiveSupport
if check!
super
else
- Null.run!
+ Null
end
end