diff options
author | Eric Wong <e@80x24.org> | 2015-02-05 17:17:42 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-02-05 17:20:45 +0000 |
commit | 682c9ffa365a2cf5439845be6e0e693d352cfe94 (patch) | |
tree | c0389bed923f7a352c8bad710ab9d164b25c9f50 /lib/unicorn | |
parent | 28bb0e47541e49f36b96725732f7a7ae260bd5e9 (diff) | |
download | unicorn-682c9ffa365a2cf5439845be6e0e693d352cfe94.tar.gz |
remove 1.8, <= 1.9.1 fallback for missing IO#autoclose=
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.
Diffstat (limited to 'lib/unicorn')
-rw-r--r-- | lib/unicorn/http_server.rb | 9 | ||||
-rw-r--r-- | 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 |