diff --git a/lib/puma/binder.rb b/lib/puma/binder.rb index 44b64be56b..f8939ac2e9 100644 --- a/lib/puma/binder.rb +++ b/lib/puma/binder.rb @@ -163,7 +163,7 @@ def parse(binds, logger, log_msg = 'Listening') ios_len = @ios.length params = Util.parse_query uri.query - opt = params.key?('low_latency') + opt = params.key?('low_latency') && params['low_latency'] != 'false' bak = params.fetch('backlog', 1024).to_i io = add_tcp_listener uri.host, uri.port, opt, bak diff --git a/lib/puma/dsl.rb b/lib/puma/dsl.rb index c6f429efb4..c4c66813ae 100644 --- a/lib/puma/dsl.rb +++ b/lib/puma/dsl.rb @@ -201,7 +201,7 @@ def load(file) # * Set the socket backlog depth with +backlog+, default is 1024. # * Set up an SSL certificate with +key+ & +cert+. # * Set whether to optimize for low latency instead of throughput with - # +low_latency+, default is to optimize for low latency. This is done + # +low_latency+, default is to not optimize for low latency. This is done # via +Socket::TCP_NODELAY+. # * Set socket permissions with +umask+. # diff --git a/test/test_binder.rb b/test/test_binder.rb index af28d82106..c4a027ab62 100644 --- a/test/test_binder.rb +++ b/test/test_binder.rb @@ -192,6 +192,33 @@ def test_pre_existing_unix end end + def test_binder_parses_nil_low_latency + skip_if :jruby + @binder.parse ["tcp://0.0.0.0:0?low_latency"], @events + + socket = @binder.listeners.first.last + + assert socket.getsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY).bool + end + + def test_binder_parses_true_low_latency + skip_if :jruby + @binder.parse ["tcp://0.0.0.0:0?low_latency=true"], @events + + socket = @binder.listeners.first.last + + assert socket.getsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY).bool + end + + def test_binder_parses_false_low_latency + skip_if :jruby + @binder.parse ["tcp://0.0.0.0:0?low_latency=false"], @events + + socket = @binder.listeners.first.last + + refute socket.getsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY).bool + end + def test_binder_parses_tlsv1_disabled skip_unless :ssl @binder.parse ["ssl://0.0.0.0:0?#{ssl_query}&no_tlsv1=true"], @events