Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for low_latency option and fix parsing issue #2631

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/puma/binder.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/puma/dsl.rb
Expand Up @@ -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+.
#
Expand Down
27 changes: 27 additions & 0 deletions test/test_binder.rb
Expand Up @@ -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
Expand Down