mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Set TCP_NODELAY on the listen socket only
All unixs inherit NODELAY from the listen socket to the sockets returned from accept(2), so you only need to set in on the listen socket once to use it on the client sockets.
This commit is contained in:
parent
8d0515e2c8
commit
281c20e353
1 changed files with 6 additions and 6 deletions
|
@ -61,8 +61,12 @@ module Puma
|
|||
}
|
||||
end
|
||||
|
||||
def add_tcp_listener(host, port)
|
||||
@ios << TCPServer.new(host, port)
|
||||
def add_tcp_listener(host, port, optimize_for_latency=true)
|
||||
s = TCPServer.new(host, port)
|
||||
if optimize_for_latency
|
||||
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
||||
end
|
||||
@ios << s
|
||||
end
|
||||
|
||||
def add_unix_listener(path)
|
||||
|
@ -126,10 +130,6 @@ module Puma
|
|||
end
|
||||
|
||||
def process_client(client)
|
||||
if client.kind_of? TCPSocket
|
||||
client.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
||||
end
|
||||
|
||||
begin
|
||||
while true
|
||||
parser = HttpParser.new
|
||||
|
|
Loading…
Reference in a new issue