mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
server.rb - properly cork & uncork ssl client (#2550)
This commit is contained in:
parent
475f8606dc
commit
e3380e9b53
3 changed files with 10 additions and 10 deletions
|
@ -1,6 +1,8 @@
|
|||
## 5.2.1 / 2021-02-
|
||||
|
||||
* Bugfixes
|
||||
* Fix TCP cork/uncork operations to work with ssl clients (#2550)
|
||||
* Require rack/common_logger explicitly if :verbose is true ([#2547])
|
||||
* MiniSSL::Socket#write - use data.byteslice(wrote..-1) ([#2543])
|
||||
* Set `@env[CONTENT_LENGTH]` value as string.
|
||||
|
||||
|
@ -20,7 +22,6 @@
|
|||
* Fix phased restart errors related to nio4r gem when using the Puma control server ([#2516])
|
||||
* Add `#string` method to `Puma::NullIO` ([#2520])
|
||||
* Fix binding via Rack handler to IPv6 addresses ([#2521])
|
||||
* Require rack/common_logger explicitly if :verbose is true ([#2547])
|
||||
|
||||
* Refactor
|
||||
* Refactor MiniSSL::Context on MRI, fix MiniSSL::Socket#write ([#2519])
|
||||
|
|
|
@ -30,7 +30,7 @@ module Puma
|
|||
#
|
||||
def handle_request(client, lines)
|
||||
env = client.env
|
||||
io = client.io
|
||||
io = client.io # io may be a MiniSSL::Socket
|
||||
|
||||
return false if closed_socket?(io)
|
||||
|
||||
|
|
|
@ -120,17 +120,13 @@ module Puma
|
|||
# :nodoc:
|
||||
# @version 5.0.0
|
||||
def tcp_cork_supported?
|
||||
RbConfig::CONFIG['host_os'] =~ /linux/ &&
|
||||
Socket.const_defined?(:IPPROTO_TCP) &&
|
||||
Socket.const_defined?(:TCP_CORK)
|
||||
Socket.const_defined?(:TCP_CORK) && Socket.const_defined?(:IPPROTO_TCP)
|
||||
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)
|
||||
Socket.const_defined?(:TCP_INFO) && Socket.const_defined?(:IPPROTO_TCP)
|
||||
end
|
||||
private :tcp_cork_supported?
|
||||
private :closed_socket_supported?
|
||||
|
@ -138,6 +134,7 @@ module Puma
|
|||
|
||||
# On Linux, use TCP_CORK to better control how the TCP stack
|
||||
# packetizes our stream. This improves both latency and throughput.
|
||||
# socket parameter may be an MiniSSL::Socket, so use to_io
|
||||
#
|
||||
if tcp_cork_supported?
|
||||
UNPACK_TCP_STATE_FROM_TCP_INFO = "C".freeze
|
||||
|
@ -146,16 +143,18 @@ module Puma
|
|||
# 3 == TCP_CORK
|
||||
# 1/0 == turn on/off
|
||||
def cork_socket(socket)
|
||||
skt = socket.to_io
|
||||
begin
|
||||
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_CORK, 1) if socket.kind_of? TCPSocket
|
||||
skt.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_CORK, 1) if skt.kind_of? TCPSocket
|
||||
rescue IOError, SystemCallError
|
||||
Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue
|
||||
end
|
||||
end
|
||||
|
||||
def uncork_socket(socket)
|
||||
skt = socket.to_io
|
||||
begin
|
||||
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_CORK, 0) if socket.kind_of? TCPSocket
|
||||
skt.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_CORK, 0) if skt.kind_of? TCPSocket
|
||||
rescue IOError, SystemCallError
|
||||
Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue