From 5221350c4c1e9a431fc06f14d3d8a695f8085ce5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 27 Feb 2010 18:26:08 -0800 Subject: don't bother supporting platforms without FD_CLOEXEC No point in having extra code around for platforms we don't care about. --- lib/rainbows.rb | 35 ++++++++++++----------------------- lib/rainbows/revactor.rb | 3 +-- 2 files changed, 13 insertions(+), 25 deletions(-) (limited to 'lib') diff --git a/lib/rainbows.rb b/lib/rainbows.rb index 9260649..f188e18 100644 --- a/lib/rainbows.rb +++ b/lib/rainbows.rb @@ -59,30 +59,19 @@ module Rainbows end # returns nil if accept fails - if defined?(Fcntl::FD_CLOEXEC) - def sync_accept(sock) - rv = sock.accept - rv.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) - rv - rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EINTR - end - - def accept(sock) - rv = sock.accept_nonblock - rv.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) - rv - rescue Errno::EAGAIN, Errno::ECONNABORTED - end - else - def sync_accept(sock) - sock.accept - rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EINTR - end + def sync_accept(sock) + rv = sock.accept + rv.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) + rv + rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EINTR + end - def accept(sock) - sock.accept_nonblock - rescue Errno::EAGAIN, Errno::ECONNABORTED - end + # returns nil if accept fails + def accept(sock) + rv = sock.accept_nonblock + rv.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) + rv + rescue Errno::EAGAIN, Errno::ECONNABORTED end end diff --git a/lib/rainbows/revactor.rb b/lib/rainbows/revactor.rb index 5c813ff..ab65184 100644 --- a/lib/rainbows/revactor.rb +++ b/lib/rainbows/revactor.rb @@ -31,8 +31,7 @@ module Rainbows # in 3 easy steps: read request, call app, write app response def process_client(client) io = client.instance_variable_get(:@_io) - defined?(Fcntl::FD_CLOEXEC) and - io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) + io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) rd_args = [ nil ] remote_addr = if ::Revactor::TCP::Socket === client rd_args << RD_ARGS -- cgit v1.2.3-24-ge0c7