0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Add backlog transport option.

This fixes issues with the http_load benchmark tool. The default backlog
option from OTP only queues up to 5 connections, which is way too low for
a fast-responding server.

Issue initially found thanks to DeadZen bugging me to test cowboy with
http_load. Fix found thanks to ostinelli's misultin already having the
backlog option which was the one thing it did differently than cowboy.
This commit is contained in:
Loïc Hoguin 2011-04-30 22:26:56 +02:00
parent c044fa9602
commit 65048fa657
2 changed files with 4 additions and 2 deletions

View file

@ -31,11 +31,12 @@ messages() -> {ssl, ssl_closed, ssl_error}.
-> {ok, LSocket::ssl:sslsocket()} | {error, Reason::atom()}. -> {ok, LSocket::ssl:sslsocket()} | {error, Reason::atom()}.
listen(Opts) -> listen(Opts) ->
{port, Port} = lists:keyfind(port, 1, Opts), {port, Port} = lists:keyfind(port, 1, Opts),
Backlog = proplists:get_value(backlog, Opts, 128),
{certfile, CertFile} = lists:keyfind(certfile, 1, Opts), {certfile, CertFile} = lists:keyfind(certfile, 1, Opts),
{keyfile, KeyFile} = lists:keyfind(keyfile, 1, Opts), {keyfile, KeyFile} = lists:keyfind(keyfile, 1, Opts),
{password, Password} = lists:keyfind(password, 1, Opts), {password, Password} = lists:keyfind(password, 1, Opts),
ssl:listen(Port, [binary, {active, false}, ssl:listen(Port, [binary, {active, false},
{packet, raw}, {reuseaddr, true}, {backlog, Backlog}, {packet, raw}, {reuseaddr, true},
{certfile, CertFile}, {keyfile, KeyFile}, {password, Password}]). {certfile, CertFile}, {keyfile, KeyFile}, {password, Password}]).
-spec accept(LSocket::ssl:sslsocket(), Timeout::timeout()) -spec accept(LSocket::ssl:sslsocket(), Timeout::timeout())

View file

@ -30,8 +30,9 @@ messages() -> {tcp, tcp_closed, tcp_error}.
-> {ok, LSocket::inet:socket()} | {error, Reason::atom()}. -> {ok, LSocket::inet:socket()} | {error, Reason::atom()}.
listen(Opts) -> listen(Opts) ->
{port, Port} = lists:keyfind(port, 1, Opts), {port, Port} = lists:keyfind(port, 1, Opts),
Backlog = proplists:get_value(backlog, Opts, 128),
gen_tcp:listen(Port, [binary, {active, false}, gen_tcp:listen(Port, [binary, {active, false},
{packet, raw}, {reuseaddr, true}]). {backlog, Backlog}, {packet, raw}, {reuseaddr, true}]).
-spec accept(LSocket::inet:socket(), Timeout::timeout()) -spec accept(LSocket::inet:socket(), Timeout::timeout())
-> {ok, Socket::inet:socket()} -> {ok, Socket::inet:socket()}