summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2009-09-14 17:03:41 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-09-15 17:33:52 +1000
commitf5a106dd61947146138148f64967122a4c9021d1 (patch)
treeaa843ece6b01f1bc6b7c8e541dd3e0da05d80212 /lib
parent19e98f994916482c930005efe938c5f0cac66dec (diff)
downloadpuppet-f5a106dd61947146138148f64967122a4c9021d1.tar.gz
puppet-f5a106dd61947146138148f64967122a4c9021d1.tar.xz
puppet-f5a106dd61947146138148f64967122a4c9021d1.zip
Fix for #2637 (Webrick accpting connections on dead sockets)
There was a race condition between the layers (SSL vs. TCP/IP) that permitted the creation of non-functional connections when webrick managed the connection. This patch moves the responsibility into our code via the provided callbacks and makes sure the socket is valid before accepting the connection. Signed-off-by: Markus Roberts <Markus@reality.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/network/http/webrick.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb
index a60a22ba1..bf4bf8859 100644
--- a/lib/puppet/network/http/webrick.rb
+++ b/lib/puppet/network/http/webrick.rb
@@ -31,13 +31,20 @@ class Puppet::Network::HTTP::WEBrick
arguments.merge!(setup_ssl)
@server = WEBrick::HTTPServer.new(arguments)
+ @server.listeners.each { |l| l.start_immediately = false }
setup_handlers
@mutex.synchronize do
raise "WEBrick server is already listening" if @listening
@listening = true
- @thread = Thread.new { @server.start }
+ @thread = Thread.new {
+ @server.start { |sock|
+ raise "Client disconnected before connection could be established" unless IO.select([sock],nil,nil,0.1)
+ sock.accept
+ @server.run(sock)
+ }
+ }
end
end