浏览代码

Allow custom nodelay socket option

Currently ibrowse defined the nodelay socket option to true, not allowing the caller
to supply its own value, which would also make the sndbuf option useless if the caller
supplied it as well.
When sending large bodies, setting nodelay to false with a custom sndbuf can improve
network throughput very significantly. For e.g., custom tests reduced an upload from
16 minutes to about 12 minutes.
pull/28/head
Filipe David Manana 14 年前
父节点
当前提交
901eb69d47
共有 1 个文件被更改,包括 11 次插入12 次删除
  1. +11
    -12
      src/ibrowse_http_client.erl

+ 11
- 12
src/ibrowse_http_client.erl 查看文件

@ -478,17 +478,19 @@ do_connect(Host, Port, Options, #state{is_ssl = true,
use_proxy = false,
ssl_options = SSLOptions},
Timeout) ->
Caller_socket_options = get_value(socket_options, Options, []),
Other_sock_options = filter_sock_options(SSLOptions ++ Caller_socket_options),
ssl:connect(Host, Port,
[binary, {nodelay, true}, {active, false} | Other_sock_options],
Timeout);
ssl:connect(Host, Port, get_sock_options(Options, SSLOptions), Timeout);
do_connect(Host, Port, Options, _State, Timeout) ->
gen_tcp:connect(Host, Port, get_sock_options(Options, []), Timeout).
get_sock_options(Options, SSLOptions) ->
Caller_socket_options = get_value(socket_options, Options, []),
Other_sock_options = filter_sock_options(Caller_socket_options),
gen_tcp:connect(Host, to_integer(Port),
[binary, {nodelay, true}, {active, false} | Other_sock_options],
Timeout).
Other_sock_options = filter_sock_options(SSLOptions ++ Caller_socket_options),
case lists:keysearch(nodelay, 1, Other_sock_options) of
false ->
[{nodelay, true}, binary, {active, false} | Other_sock_options];
{value, _} ->
[binary, {active, false} | Other_sock_options]
end.
%% We don't want the caller to specify certain options
filter_sock_options(Opts) ->
@ -1809,8 +1811,5 @@ trace_request_body(Body) ->
ok
end.
to_integer(X) when is_list(X) -> list_to_integer(X);
to_integer(X) when is_integer(X) -> X.
to_binary(X) when is_list(X) -> list_to_binary(X);
to_binary(X) when is_binary(X) -> X.

正在加载...
取消
保存