Can some FreeBSD users review this? Thank you. This issue was reported privately by a FreeBSD 8.1-RELEASE user.
>From a837437b4ca7903b3fcb90af1f257d841c9bd22f Mon Sep 17 00:00:00 2001 From: Eric Wong <[email protected]> Date: Sat, 2 Jun 2012 19:29:58 +0000 Subject: [PATCH] FreeBSD: do not attempt to set TCP_NOPUSH to false Instead of blindly turning TCP_NOPUSH off when setting up the listen socket, only enable TCP_NOPUSH (if requested by the user) but never disable it. A FreeBSD 8.1-RELEASE user privately reported EADDRNOTAVAIL errors when setting up the TCP listener due to the default (tcp_nopush: false) value: ERROR -- : $HOST:$PORT{:tcp_defer_accept=>1, :accept_filter=>"httpready", :backlog=>1024, :tcp_nopush=>false, :tcp_nodelay=>true}: Can't assign requested address (Errno::EADDRNOTAVAIL)* Additionally, the user reported the listen(backlog: 1024) value got dropped and reset back to 5. This unfortunately means we won't be able disable TCP_NOPUSH once turned on (via SIGHUP/SIGUSR2). --- lib/unicorn/socket_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/unicorn/socket_helper.rb b/lib/unicorn/socket_helper.rb index 21c52e3..1a6e374 100644 --- a/lib/unicorn/socket_helper.rb +++ b/lib/unicorn/socket_helper.rb @@ -66,7 +66,8 @@ module Unicorn val = val ? 1 : 0 if defined?(TCP_CORK) # Linux sock.setsockopt(IPPROTO_TCP, TCP_CORK, val) - elsif defined?(TCP_NOPUSH) # TCP_NOPUSH is untested (FreeBSD) + elsif defined?(TCP_NOPUSH) && val == 1 + # TCP_NOPUSH is lightly-tested (FreeBSD) sock.setsockopt(IPPROTO_TCP, TCP_NOPUSH, val) end -- Eric Wong _______________________________________________ Unicorn mailing list - [email protected] http://rubyforge.org/mailman/listinfo/mongrel-unicorn Do not quote signatures (like this one) or top post when replying
