aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-10-06 10:31:14 +1030
committerMatthew Draper <matthew@trebex.net>2016-10-06 10:31:14 +1030
commit4a7c5685c86d0349c98b2725ad01aa70ebcc3581 (patch)
treebaadb3ec9881ed879203967f993fcbd19196a14a
parentde9a56b66af928a09f85daf15ffb1c2023a7c1b8 (diff)
downloadrails-4a7c5685c86d0349c98b2725ad01aa70ebcc3581.tar.gz
rails-4a7c5685c86d0349c98b2725ad01aa70ebcc3581.tar.bz2
rails-4a7c5685c86d0349c98b2725ad01aa70ebcc3581.zip
Close the IO from the read loop thread
IO#close and IO#read across threads don't get along so well: After T1 enters #read and releases the GVL, T2 can call #close on the IO, thereby both closing the fd and freeing the buffer while T1 is using them.
-rw-r--r--actioncable/lib/action_cable/connection/stream.rb1
-rw-r--r--actioncable/lib/action_cable/connection/stream_event_loop.rb1
2 files changed, 1 insertions, 1 deletions
diff --git a/actioncable/lib/action_cable/connection/stream.rb b/actioncable/lib/action_cable/connection/stream.rb
index d66e1b4e41..e620b93845 100644
--- a/actioncable/lib/action_cable/connection/stream.rb
+++ b/actioncable/lib/action_cable/connection/stream.rb
@@ -106,7 +106,6 @@ module ActionCable
def clean_rack_hijack
return unless @rack_hijack_io
@event_loop.detach(@rack_hijack_io, self)
- @rack_hijack_io.close
@rack_hijack_io = nil
end
end
diff --git a/actioncable/lib/action_cable/connection/stream_event_loop.rb b/actioncable/lib/action_cable/connection/stream_event_loop.rb
index eec24638b6..2d1af0ff9f 100644
--- a/actioncable/lib/action_cable/connection/stream_event_loop.rb
+++ b/actioncable/lib/action_cable/connection/stream_event_loop.rb
@@ -36,6 +36,7 @@ module ActionCable
@todo << lambda do
@nio.deregister io
@map.delete io
+ io.close
end
wakeup
end