diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-08-17 08:35:03 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-08-17 08:41:15 +0000 |
commit | ac05e7035e1946b78ce4679548db7680aa01734c (patch) | |
tree | 1379997b2686b9fa777216ad06f1ffe9be5b6027 /lib/rainbows.rb | |
parent | 9c5669e232f8f57c2d8e08d84e21bf09cd87bfa1 (diff) | |
download | rainbows-ac05e7035e1946b78ce4679548db7680aa01734c.tar.gz |
First off we use an FD_MAP to avoid creating redundant IO objects which map to the same FD. When that doesn't work, we'll fall back to trapping Errno::EBADF and IOError where appropriate.
Diffstat (limited to 'lib/rainbows.rb')
-rw-r--r-- | lib/rainbows.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/rainbows.rb b/lib/rainbows.rb index 04d5ebc..2faf3c8 100644 --- a/lib/rainbows.rb +++ b/lib/rainbows.rb @@ -30,6 +30,12 @@ module Rainbows G = State.new(true, 0, 0, 5) O = {} class Response416 < RangeError; end + + # map of numeric file descriptors to IO objects to avoid using IO.new + # and potentially causing race conditions when using /dev/fd/ + FD_MAP = {} + FD_MAP.compare_by_identity if FD_MAP.respond_to?(:compare_by_identity) + # :startdoc: require 'rainbows/const' |