Skip to content

Commit 9cbf3b3

Browse files
matthewdrafaelfranca
authored andcommitted
Merge pull request rails#25615 from tinco/close_hijacked_socket
close hijacked i/o socket after use (fixes rails#25613)
1 parent ae40629 commit 9cbf3b3

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

actioncable/lib/action_cable/connection/stream.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def hijack_rack_socket
5050
def clean_rack_hijack
5151
return unless @rack_hijack_io
5252
@event_loop.detach(@rack_hijack_io, self)
53+
@rack_hijack_io.close
5354
@rack_hijack_io = nil
5455
end
5556
end

actioncable/test/connection/client_socket_test.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ def on_error(message)
4848
end
4949
end
5050

51+
test 'closes hijacked i/o socket at shutdown' do
52+
skip if ENV['FAYE'].present?
53+
54+
run_in_eventmachine do
55+
connection = open_connection
56+
57+
client = connection.websocket.send(:websocket)
58+
client.instance_variable_get('@stream')
59+
.instance_variable_get('@rack_hijack_io')
60+
.expects(:close)
61+
connection.close
62+
end
63+
end
64+
5165
private
5266
def open_connection
5367
env = Rack::MockRequest.env_for '/test',

0 commit comments

Comments
 (0)