From 602784e227c3d792c492ffd45df81182eb0fa9dc Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 3 Jul 2015 08:50:25 +0000 Subject: apply TCP socket options on inherited sockets TCP socket options are now set when inheriting existing sockets from a parent process. I'm fairly certain all the TCP setsockopt knobs we use are idempotent and harmless to change. If anything, the only directive I'd be uncomfortable changing is shortening the listen(2) (aka :backlog) size, but we've always changed that anyways since it also applies to UNIX sockets. Note: removing a configuration knob in a yahns config file can not reset the value to the OS-provided default setting. Inherited sockets must use a new setting to override existing ones. (or the socket needs to be closed and re-created in the process launcher before yahns inherits it). Based on unicorn commit 1db9a8243d42cc86d5ca4901bceb305061d0d212 Noticed-by: Christos Trochalakis <20150626114129.GA25883@luke.ws.skroutz.gr> --- lib/yahns/server.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/yahns/server.rb b/lib/yahns/server.rb index 3b9addc..b6663e1 100644 --- a/lib/yahns/server.rb +++ b/lib/yahns/server.rb @@ -315,9 +315,10 @@ class Yahns::Server # :nodoc: inherited = ENV['YAHNS_FD'].to_s.split(',').map! do |fd| io = Socket.for_fd(fd.to_i) opts = sock_opts(io) + io = server_cast(io, opts) set_server_sockopt(io, opts) @logger.info "inherited addr=#{sock_name(io)} fd=#{fd}" - server_cast(io, opts) + io end @listeners.replace(inherited) -- cgit v1.2.3-24-ge0c7