From: Eric Wong <e@80x24.org>
To: unicorn-public@bogomips.org
Subject: [PATCH] remove 1.8, <= 1.9.1 fallback for missing IO#autoclose=
Date: Thu, 5 Feb 2015 18:01:22 +0000 [thread overview]
Message-ID: <1423159284-31112-1-git-send-email-e@80x24.org> (raw)
We're requiring Ruby 1.9.3+, so we can safely depend
on IO#autoclose= being available in 1.9+ and shave off
some bloat.
---
lib/unicorn/http_server.rb | 9 +++------
lib/unicorn/socket_helper.rb | 14 +-------------
2 files changed, 4 insertions(+), 19 deletions(-)
diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb
index e0c0370..8a295f0 100644
--- a/lib/unicorn/http_server.rb
+++ b/lib/unicorn/http_server.rb
@@ -156,9 +156,6 @@ class Unicorn::HttpServer
LISTENERS.delete_if do |io|
if dead_names.include?(sock_name(io))
- IO_PURGATORY.delete_if do |pio|
- pio.fileno == io.fileno && (pio.close rescue nil).nil? # true
- end
(io.close rescue nil).nil? # true
else
set_server_sockopt(io, listener_opts[sock_name(io)])
@@ -239,7 +236,7 @@ class Unicorn::HttpServer
begin
io = bind_listen(address, opt)
unless Kgio::TCPServer === io || Kgio::UNIXServer === io
- prevent_autoclose(io)
+ io.autoclose = false
io = server_cast(io)
end
logger.info "listening on addr=#{sock_name(io)} fd=#{io.fileno}"
@@ -453,7 +450,7 @@ class Unicorn::HttpServer
(3..1024).each do |io|
next if listener_fds.include?(io)
io = IO.for_fd(io) rescue next
- prevent_autoclose(io)
+ io.autoclose = false
io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
end
@@ -770,7 +767,7 @@ class Unicorn::HttpServer
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)])
- prevent_autoclose(io)
+ io.autoclose = false
logger.info "inherited addr=#{sock_name(io)} fd=#{fd}"
server_cast(io)
end
diff --git a/lib/unicorn/socket_helper.rb b/lib/unicorn/socket_helper.rb
index 2ecf438..a4247ac 100644
--- a/lib/unicorn/socket_helper.rb
+++ b/lib/unicorn/socket_helper.rb
@@ -5,10 +5,6 @@ require 'socket'
module Unicorn
module SocketHelper
- # prevents IO objects in here from being GC-ed
- # kill this when we drop 1.8 support
- IO_PURGATORY = []
-
# internal interface, only used by Rainbows!/Zbatery
DEFAULTS = {
# The semantics for TCP_DEFER_ACCEPT changed in Linux 2.6.32+
@@ -36,14 +32,6 @@ module Unicorn
[ af_name, nil ].pack('a16a240')
end if RUBY_PLATFORM =~ /freebsd/ && Socket.const_defined?(:SO_ACCEPTFILTER)
- def prevent_autoclose(io)
- if io.respond_to?(:autoclose=)
- io.autoclose = false
- else
- IO_PURGATORY << io
- end
- end
-
def set_tcp_sockopt(sock, opt)
# just in case, even LANs can break sometimes. Linux sysadmins
# can lower net.ipv4.tcp_keepalive_* sysctl knobs to very low values.
@@ -161,7 +149,7 @@ module Unicorn
sock.setsockopt(:SOL_SOCKET, :SO_REUSEPORT, 1)
end
sock.bind(Socket.pack_sockaddr_in(port, addr))
- prevent_autoclose(sock)
+ sock.autoclose = false
Kgio::TCPServer.for_fd(sock.fileno)
end
--
EW
reply other threads:[~2015-02-05 18:01 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=1423159284-31112-1-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=unicorn-public@bogomips.org \
/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).