unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: unicorn-public@bogomips.org
Cc: Christos Trochalakis <yatiohi@ideopolis.gr>, Eric Wong <e@80x24.org>
Subject: [PATCH] apply TCP socket options on inherited sockets
Date: Sat, 27 Jun 2015 02:57:59 +0000	[thread overview]
Message-ID: <1435373879-4299-1-git-send-email-e@80x24.org> (raw)

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 unicorn 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 unicorn inherits it).

Noticed-by: Christos Trochalakis <yatiohi@ideopolis.gr>
  <20150626114129.GA25883@luke.ws.skroutz.gr>
---
 lib/unicorn/http_server.rb | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb
index 3282ec7..297b9f9 100644
--- a/lib/unicorn/http_server.rb
+++ b/lib/unicorn/http_server.rb
@@ -768,10 +768,11 @@ def inherit_listeners!
     # before they become Kgio::UNIXServer or Kgio::TCPServer
     inherited = ENV['UNICORN_FD'].to_s.split(',').map do |fd|
       io = Socket.for_fd(fd.to_i)
-      set_server_sockopt(io, listener_opts[sock_name(io)])
       io.autoclose = false
+      io = server_cast(io)
+      set_server_sockopt(io, listener_opts[sock_name(io)])
       logger.info "inherited addr=#{sock_name(io)} fd=#{fd}"
-      server_cast(io)
+      io
     end
 
     config_listeners = config[:listeners].dup
-- 
EW


                 reply	other threads:[~2015-06-27  2:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1435373879-4299-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=unicorn-public@bogomips.org \
    --cc=yatiohi@ideopolis.gr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).