diff options
author | Matthew Draper <matthew@trebex.net> | 2016-10-03 05:36:44 +1030 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-03 05:36:44 +1030 |
commit | 4f8e336c44378e819ce36cb291bc6e9dce0cc7e0 (patch) | |
tree | 726f626c3637326e0f2b2c24b767bbfaba18c681 | |
parent | 9128ba5cd496eed89e14f92f7b3fdbed1bdf5750 (diff) | |
parent | d1cc11a360ce9b6ede838c5de5523fc421472487 (diff) | |
download | rails-4f8e336c44378e819ce36cb291bc6e9dce0cc7e0.tar.gz rails-4f8e336c44378e819ce36cb291bc6e9dce0cc7e0.tar.bz2 rails-4f8e336c44378e819ce36cb291bc6e9dce0cc7e0.zip |
Merge pull request #26620 from maclover7/jm-ac-pg-bug
Shutdown pubsub connection before classes are reloaded
-rw-r--r-- | actioncable/lib/action_cable/server/base.rb | 8 | ||||
-rw-r--r-- | actioncable/test/server/base_test.rb | 33 |
2 files changed, 39 insertions, 2 deletions
diff --git a/actioncable/lib/action_cable/server/base.rb b/actioncable/lib/action_cable/server/base.rb index 67ada7cc2e..419eccd73c 100644 --- a/actioncable/lib/action_cable/server/base.rb +++ b/actioncable/lib/action_cable/server/base.rb @@ -37,9 +37,13 @@ module ActionCable connections.each(&:close) @mutex.synchronize do - worker_pool.halt if @worker_pool - + # Shutdown the worker pool + @worker_pool.halt if @worker_pool @worker_pool = nil + + # Shutdown the pub/sub adapter + @pubsub.shutdown if @pubsub + @pubsub = nil end end diff --git a/actioncable/test/server/base_test.rb b/actioncable/test/server/base_test.rb new file mode 100644 index 0000000000..f0a51c5a7d --- /dev/null +++ b/actioncable/test/server/base_test.rb @@ -0,0 +1,33 @@ +require "test_helper" +require "stubs/test_server" +require "active_support/core_ext/hash/indifferent_access" + +class BaseTest < ActiveSupport::TestCase + def setup + @server = ActionCable::Server::Base.new + @server.config.cable = { adapter: "async" }.with_indifferent_access + end + + class FakeConnection + def close + end + end + + test "#restart closes all open connections" do + conn = FakeConnection.new + @server.add_connection(conn) + + conn.expects(:close) + @server.restart + end + + test "#restart shuts down worker pool" do + @server.worker_pool.expects(:halt) + @server.restart + end + + test "#restart shuts down pub/sub adapter" do + @server.pubsub.expects(:shutdown) + @server.restart + end +end |