From 5c5cff9ab839b32d32f762eedc94ab39acde663c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 1 Apr 2009 11:28:51 -0700 Subject: Remove set_cloexec wrapper and require FD_CLOEXEC FD_CLOEXEC is POSIX and we only run on POSIX. Things will slowly leak over time if FD_CLOEXEC is not set, so raise the issue ASAP. --- lib/unicorn.rb | 3 ++- lib/unicorn/socket.rb | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index cbbb283..3bdbb3a 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -1,4 +1,5 @@ require 'logger' +require 'fcntl' require 'unicorn/socket' require 'unicorn/const' @@ -425,7 +426,7 @@ module Unicorn @workers.clear @start_ctx.clear @start_ctx = @workers = @rd_sig = @wr_sig = nil - @listeners.each { |sock| set_cloexec(sock) } + @listeners.each { |sock| sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) } ENV.delete('UNICORN_FD') @after_fork.call(self, worker.nr) if @after_fork @request = HttpRequest.new(logger) diff --git a/lib/unicorn/socket.rb b/lib/unicorn/socket.rb index 4870133..0dba8cb 100644 --- a/lib/unicorn/socket.rb +++ b/lib/unicorn/socket.rb @@ -1,4 +1,3 @@ -require 'fcntl' require 'socket' require 'io/nonblock' @@ -48,10 +47,6 @@ module Unicorn sock.setsockopt(SOL_TCP, TCP_CORK, 1) if defined?(TCP_CORK) end - def set_cloexec(io) - io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined?(Fcntl::FD_CLOEXEC) - end - def set_server_sockopt(sock) if defined?(TCP_DEFER_ACCEPT) sock.setsockopt(SOL_TCP, TCP_DEFER_ACCEPT, 1) rescue nil -- cgit v1.2.3-24-ge0c7