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.
This commit is contained in:
Matthew Draper 2016-10-06 10:31:14 +10:30
parent de9a56b66a
commit 4a7c5685c8
2 changed files with 1 additions and 1 deletions

@ -106,7 +106,6 @@ def hijack_rack_socket
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

@ -36,6 +36,7 @@ def detach(io, stream)
@todo << lambda do
@nio.deregister io
@map.delete io
io.close
end
wakeup
end