summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-08-06 20:15:46 +0000
committerEric Wong <normalperson@yhbt.net>2012-08-06 20:15:46 +0000
commit7b107d66e84ad2e958d5574cb00770265dd117c2 (patch)
tree16350d8608c3ad13bf22a1028747cd2211234d09
parent53c375dc933b62b24df2c54d3938b03fa9da1f06 (diff)
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.
-rw-r--r--lib/unicorn/socket_helper.rb14
1 files 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