diff options
author | Matthew Draper <matthew@trebex.net> | 2016-02-25 13:58:31 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-02-25 13:58:31 +1030 |
commit | 50e4433b051829350984f0c5eb1271243f6d229d (patch) | |
tree | 49b981022945253872271314cfe77dcc9aea59a8 /actioncable/lib | |
parent | 9e30869c9af4aa5a76d9c63cd9ac080aa3f1ac39 (diff) | |
parent | a536cc8f1e31e09526b6b43c07ec255d66cd2049 (diff) | |
download | rails-50e4433b051829350984f0c5eb1271243f6d229d.tar.gz rails-50e4433b051829350984f0c5eb1271243f6d229d.tar.bz2 rails-50e4433b051829350984f0c5eb1271243f6d229d.zip |
Merge pull request #23843 from maclover7/fix-23471
Only hijack Rack socket when first needed
Diffstat (limited to 'actioncable/lib')
-rw-r--r-- | actioncable/lib/action_cable/connection/client_socket.rb | 1 | ||||
-rw-r--r-- | actioncable/lib/action_cable/connection/stream.rb | 18 |
2 files changed, 9 insertions, 10 deletions
diff --git a/actioncable/lib/action_cable/connection/client_socket.rb b/actioncable/lib/action_cable/connection/client_socket.rb index 95e1ac4c16..d7632b05fe 100644 --- a/actioncable/lib/action_cable/connection/client_socket.rb +++ b/actioncable/lib/action_cable/connection/client_socket.rb @@ -58,6 +58,7 @@ module ActionCable def start_driver return if @driver.nil? || @driver_started + @stream.hijack_rack_socket @driver_started = true @driver.start end diff --git a/actioncable/lib/action_cable/connection/stream.rb b/actioncable/lib/action_cable/connection/stream.rb index ace250cd16..2d97b28c09 100644 --- a/actioncable/lib/action_cable/connection/stream.rb +++ b/actioncable/lib/action_cable/connection/stream.rb @@ -4,15 +4,13 @@ module ActionCable # This class is heavily based on faye-websocket-ruby # # Copyright (c) 2010-2015 James Coglan - class Stream + class Stream # :nodoc: def initialize(event_loop, socket) @event_loop = event_loop @socket_object = socket @stream_send = socket.env['stream.send'] @rack_hijack_io = nil - - hijack_rack_socket end def each(&callback) @@ -39,16 +37,16 @@ module ActionCable @socket_object.parse(data) end - private - def hijack_rack_socket - return unless @socket_object.env['rack.hijack'] + def hijack_rack_socket + return unless @socket_object.env['rack.hijack'] - @socket_object.env['rack.hijack'].call - @rack_hijack_io = @socket_object.env['rack.hijack_io'] + @socket_object.env['rack.hijack'].call + @rack_hijack_io = @socket_object.env['rack.hijack_io'] - @event_loop.attach(@rack_hijack_io, self) - end + @event_loop.attach(@rack_hijack_io, self) + end + private def clean_rack_hijack return unless @rack_hijack_io @event_loop.detach(@rack_hijack_io, self) |