diff options
author | Eric Wong <e@80x24.org> | 2017-03-10 23:01:17 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-03-14 20:08:06 +0000 |
commit | ab11a4da17f5ccfc4a2a21cd4c5090627b31c3b9 (patch) | |
tree | 78993a46d2f17a89f24590ed36feb626b58fa5dd /lib | |
parent | 59e39cbc68c49623949b3e5c2d7e113e96e90a27 (diff) | |
download | unicorn-ab11a4da17f5ccfc4a2a21cd4c5090627b31c3b9.tar.gz |
Accept filters can only be set on listen sockets, and it also fails with EINVAL if it's already set. Untested, but I suppose changing the accept filter on a listening socket is not supported, either; since that could affect in-flight sockets.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/unicorn/socket_helper.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/unicorn/socket_helper.rb b/lib/unicorn/socket_helper.rb index df8315e..7aa2bb0 100644 --- a/lib/unicorn/socket_helper.rb +++ b/lib/unicorn/socket_helper.rb @@ -63,12 +63,15 @@ module Unicorn elsif respond_to?(:accf_arg) name = opt[:accept_filter] name = DEFAULTS[:accept_filter] if name.nil? + sock.listen(opt[:backlog]) + got = (sock.getsockopt(:SOL_SOCKET, :SO_ACCEPTFILTER) rescue nil).to_s + arg = accf_arg(name) begin - sock.setsockopt(:SOL_SOCKET, :SO_ACCEPTFILTER, accf_arg(name)) + sock.setsockopt(:SOL_SOCKET, :SO_ACCEPTFILTER, arg) rescue => e logger.error("#{sock_name(sock)} " \ "failed to set accept_filter=#{name} (#{e.inspect})") - end + end if arg != got end end |