From 7b107d66e84ad2e958d5574cb00770265dd117c2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 6 Aug 2012 20:15:46 +0000 Subject: do not touch TCP_NOPUSH/TCP_CORK at all by default On a certain FreeBSD 8.1 installation, explicitly setting TCP_NOPUSH to zero (off) can cause EADDRNOTAVAIL errors and also resets the listen backlog to 5. Enabling TCP_NOPUSH explicitly did not exhibit this issue for the user who (privately) reported this issue. To be on the safe side, we won't set/unset TCP_NOPUSH/TCP_CORK at all, which will leave it off on all current systems. --- lib/unicorn/socket_helper.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/unicorn/socket_helper.rb b/lib/unicorn/socket_helper.rb index 21c52e3..18b0be7 100644 --- a/lib/unicorn/socket_helper.rb +++ b/lib/unicorn/socket_helper.rb @@ -28,7 +28,7 @@ module Unicorn :backlog => 1024, # favor latency over bandwidth savings - :tcp_nopush => false, + :tcp_nopush => nil, :tcp_nodelay => true, } #:startdoc: @@ -62,12 +62,12 @@ module Unicorn end val = opt[:tcp_nopush] - val = DEFAULTS[:tcp_nopush] if nil == val - 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) - sock.setsockopt(IPPROTO_TCP, TCP_NOPUSH, val) + unless val.nil? + if defined?(TCP_CORK) # Linux + sock.setsockopt(IPPROTO_TCP, TCP_CORK, val) + elsif defined?(TCP_NOPUSH) # TCP_NOPUSH is lightly tested (FreeBSD) + sock.setsockopt(IPPROTO_TCP, TCP_NOPUSH, val) + end end # No good reason to ever have deferred accepts off -- cgit v1.2.3-24-ge0c7