summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-06-05 18:12:42 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-06-05 18:12:42 +0000
commit992636af76a91069ce42099e096deb9febb7d06c (patch)
tree24ad62df684ae584d45a5cc4591dcfa27a105be0
parent1867d0eba516b45c0db40158075d1a2c13b83f1d (diff)
downloadpuppet-992636af76a91069ce42099e096deb9febb7d06c.tar.gz
puppet-992636af76a91069ce42099e096deb9febb7d06c.tar.xz
puppet-992636af76a91069ce42099e096deb9febb7d06c.zip
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
-rw-r--r--CHANGELOG3
-rw-r--r--lib/puppet/external/event-loop/event-loop.rb4
-rw-r--r--lib/puppet/network/server/webrick.rb13
3 files changed, 19 insertions, 1 deletions
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,