diff options
author | Siri Hansen <siri@erlang.org> | 2015-09-28 15:37:41 +0200 |
---|---|---|
committer | Siri Hansen <siri@erlang.org> | 2015-09-28 15:37:41 +0200 |
commit | 67b38c36eaa9b6d3edb80df75637f0e8cd1823f3 (patch) | |
tree | b1d7f7a01f70790b95444192c72e64350ae41874 /lib/common_test/test/ct_netconfc_SUITE_data/ns.erl | |
parent | 71501e4307e78805bda531c78352913d12e1dfc9 (diff) | |
download | erlang-67b38c36eaa9b6d3edb80df75637f0e8cd1823f3.tar.gz |
Speed up receive of many small packages
When data from the netconf server was split into many ssh packages,
the netconf client performed really bad. This is now improved.
Diffstat (limited to 'lib/common_test/test/ct_netconfc_SUITE_data/ns.erl')
-rw-r--r-- | lib/common_test/test/ct_netconfc_SUITE_data/ns.erl | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl b/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl index 8c30383343..3fc99e5486 100644 --- a/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl +++ b/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl @@ -277,6 +277,18 @@ hupp_kill(State = #session{connection = ConnRef}) -> send({CM,Ch},Data) -> ssh_connection:send(CM, Ch, Data). +%%% Split into many small parts and send to client +send_frag({CM,Ch},Data) -> + Sz = rand:uniform(2000), + case Data of + <<Chunk:Sz/binary,Rest/binary>> -> + ssh_connection:send(CM, Ch, Chunk), + send_frag({CM,Ch},Rest); + Chunk -> + ssh_connection:send(CM, Ch, Chunk) + end. + + %%% Kill ssh connection kill({CM,_Ch}) -> ssh:close(CM). @@ -424,6 +436,9 @@ do(_, undefined) -> reply(_,undefined) -> ?dbg("no reply~n",[]), ok; +reply(ConnRef,{fragmented,Reply}) -> + ?dbg("Reply fragmented: ~p~n",[Reply]), + send_frag(ConnRef,make_msg(Reply)); reply(ConnRef,Reply) -> ?dbg("Reply: ~p~n",[Reply]), send(ConnRef, make_msg(Reply)). |