1
0
Fork 0
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:
Evan Phoenix 2011-11-30 21:30:12 -08:00
parent 8d0515e2c8
commit 281c20e353

View file

@ -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