Skip to content

Commit

Permalink
split TCP_CORK and TCP_INFO (#2372)
Browse files Browse the repository at this point in the history
Co-authored-by: pavel <pavel.rosicky@easy.cz>
  • Loading branch information
ahorek and ahorek committed Sep 22, 2020
1 parent 7d00e1d commit 7928173
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions lib/puma/server.rb
Expand Up @@ -101,10 +101,18 @@ class << self
def tcp_cork_supported?
RbConfig::CONFIG['host_os'] =~ /linux/ &&
Socket.const_defined?(:IPPROTO_TCP) &&
Socket.const_defined?(:TCP_CORK) &&
Socket.const_defined?(:TCP_CORK)
end

# :nodoc:
# @version 5.0.0
def closed_socket_supported?
RbConfig::CONFIG['host_os'] =~ /linux/ &&
Socket.const_defined?(:IPPROTO_TCP) &&
Socket.const_defined?(:TCP_INFO)
end
private :tcp_cork_supported?
private :closed_socket_supported?
end

# On Linux, use TCP_CORK to better control how the TCP stack
Expand All @@ -131,7 +139,15 @@ def uncork_socket(socket)
Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue
end
end
else
def cork_socket(socket)
end

def uncork_socket(socket)
end
end

if closed_socket_supported?
def closed_socket?(socket)
return false unless socket.kind_of? TCPSocket
return false unless @precheck_closing
Expand All @@ -149,12 +165,6 @@ def closed_socket?(socket)
end
end
else
def cork_socket(socket)
end

def uncork_socket(socket)
end

def closed_socket?(socket)
false
end
Expand Down

0 comments on commit 7928173

Please sign in to comment.