about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-04-01 11:28:51 -0700
committerEric Wong <normalperson@yhbt.net>2009-04-01 11:28:51 -0700
commit5c5cff9ab839b32d32f762eedc94ab39acde663c (patch)
treeae362fa8c4f0c1bf003aa03f936865f3241f2a2c
parentf1bf2add4bdb0260333ca167c3b9d192c5cc2929 (diff)
downloadunicorn-5c5cff9ab839b32d32f762eedc94ab39acde663c.tar.gz
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.
-rw-r--r--lib/unicorn.rb3
-rw-r--r--lib/unicorn/socket.rb5
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