diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-08-02 04:52:21 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-08-02 04:52:21 +0000 |
commit | 41d9de49f9adf49b50b034ece6ea5a58688a6cce (patch) | |
tree | 19f36d92cbcc03afcd434dbaa5e609d148225dda /lib/rainbows | |
parent | 3a96720e4e0f1d14599b9fae10e210110976e0c5 (diff) | |
download | rainbows-41d9de49f9adf49b50b034ece6ea5a58688a6cce.tar.gz |
EventMachine may close the underlying file descriptor on us if there are unrecoverable errors during write. So IO#closed? is a pointless check because EM does not invalidate the underlying file descriptor.
Diffstat (limited to 'lib/rainbows')
-rw-r--r-- | lib/rainbows/event_machine.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb index 757817d..a0b9ca6 100644 --- a/lib/rainbows/event_machine.rb +++ b/lib/rainbows/event_machine.rb @@ -157,7 +157,14 @@ module Rainbows def unbind async_close = @env[ASYNC_CLOSE] and async_close.succeed @body.respond_to?(:fail) and @body.fail - @_io.close unless @_io.closed? + begin + @_io.close + rescue Errno::EBADF + # EventMachine's EventableDescriptor::Close() may close + # the underlying file descriptor without invalidating the + # associated IO object on errors, so @_io.closed? isn't + # sufficient. + end end end |