From 992636af76a91069ce42099e096deb9febb7d06c Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 5 Jun 2007 18:12:42 +0000 Subject: Applying patches from Valentin Vidic to fix open file discriptor and open port problems git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2553 980ebf18-57e1-0310-9a29-db15c13687c0 --- CHANGELOG | 3 +++ lib/puppet/external/event-loop/event-loop.rb | 4 ++++ lib/puppet/network/server/webrick.rb | 13 ++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index fd5e64c29..f053ce238 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ + Hopefully fixing the file descriptor/open port problems, with patches + from Valentin Vidic. + Significantly reworked the type => provider interface with respect to listing existing provider instances. The class method on both class heirarchies has been renamed to 'instances', to start. Providers diff --git a/lib/puppet/external/event-loop/event-loop.rb b/lib/puppet/external/event-loop/event-loop.rb index 6e40d275c..17a520ead 100644 --- a/lib/puppet/external/event-loop/event-loop.rb +++ b/lib/puppet/external/event-loop/event-loop.rb @@ -74,6 +74,10 @@ class EventLoop @notify_src, @notify_snk = IO.pipe + # prevent file descriptor leaks + @notify_src.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) + @notify_snk.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) + @notify_src.will_block = false @notify_snk.will_block = false diff --git a/lib/puppet/network/server/webrick.rb b/lib/puppet/network/server/webrick.rb index 135625710..3af0cfd3f 100644 --- a/lib/puppet/network/server/webrick.rb +++ b/lib/puppet/network/server/webrick.rb @@ -2,6 +2,7 @@ require 'puppet' require 'puppet/daemon' require 'webrick' require 'webrick/https' +require 'fcntl' require 'puppet/sslcertificates/support' require 'puppet/network/xmlrpc/webrick_servlet' @@ -54,7 +55,12 @@ module Puppet file = Puppet[:httplog] end - args << file + # open the log manually to prevent file descriptor leak + file_io = open(file, "a+") + file_io.sync + file_io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) + + args << file_io if Puppet[:debug] args << WEBrick::Log::DEBUG end @@ -87,6 +93,11 @@ module Puppet super(hash) + # make sure children don't inherit the sockets + listeners.each { |sock| + sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) + } + Puppet.info "Listening on port %s" % hash[:Port] # this creates a new servlet for every connection, -- cgit