From f3d2528834440ace5b33f1ba1efd7a4fff7c53b1 Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Mon, 19 Dec 2011 10:39:09 -0800 Subject: [PATCH] Make the backlog count configurable --- lib/puma/server.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/puma/server.rb b/lib/puma/server.rb index 194a14f5..befb3747 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -92,15 +92,18 @@ module Puma end # Tell the server to listen on host +host+, port +port+. - # If optimize_for_latency is true (the default) then clients connecting + # If +optimize_for_latency+ is true (the default) then clients connecting # will be optimized for latency over throughput. # - def add_tcp_listener(host, port, optimize_for_latency=true) + # +backlog+ indicates how many unaccepted connections the kernel should + # allow to accumulate before returning connection refused. + # + def add_tcp_listener(host, port, optimize_for_latency=true, backlog=1024) s = TCPServer.new(host, port) if optimize_for_latency s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) end - s.listen 1024 + s.listen backlog @ios << s end