diff options
author | Siri Hansen <[email protected]> | 2015-09-28 15:37:41 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2015-09-28 15:37:41 +0200 |
commit | 67b38c36eaa9b6d3edb80df75637f0e8cd1823f3 (patch) | |
tree | b1d7f7a01f70790b95444192c72e64350ae41874 /lib/common_test/src/ct_netconfc.erl | |
parent | 71501e4307e78805bda531c78352913d12e1dfc9 (diff) | |
download | otp-67b38c36eaa9b6d3edb80df75637f0e8cd1823f3.tar.gz otp-67b38c36eaa9b6d3edb80df75637f0e8cd1823f3.tar.bz2 otp-67b38c36eaa9b6d3edb80df75637f0e8cd1823f3.zip |
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/src/ct_netconfc.erl')
-rw-r--r-- | lib/common_test/src/ct_netconfc.erl | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/common_test/src/ct_netconfc.erl b/lib/common_test/src/ct_netconfc.erl index 0de7bf03af..799d795ed0 100644 --- a/lib/common_test/src/ct_netconfc.erl +++ b/lib/common_test/src/ct_netconfc.erl @@ -1366,11 +1366,18 @@ to_xml_doc(Simple) -> %%% Parse and handle received XML data handle_data(NewData,#state{connection=Connection,buff=Buff0} = State0) -> log(Connection,recv,NewData), - Data = append_wo_initial_nl(Buff0,NewData), - case binary:split(Data,[?END_TAG],[]) of + {Start,AddSz} = + case byte_size(Buff0) of + BSz when BSz<5 -> {0,BSz}; + BSz -> {BSz-5,5} + end, + Length = byte_size(NewData) + AddSz, + Data = <<Buff0/binary, NewData/binary>>, + case binary:split(Data,?END_TAG,[{scope,{Start,Length}}]) of [_NoEndTagFound] -> {noreply, State0#state{buff=Data}}; - [FirstMsg,Buff1] -> + [FirstMsg0,Buff1] -> + FirstMsg = remove_initial_nl(FirstMsg0), SaxArgs = [{event_fun,fun sax_event/3}, {event_state,[]}], case xmerl_sax_parser:stream(FirstMsg, SaxArgs) of {ok, Simple, _Thrash} -> @@ -1392,11 +1399,10 @@ handle_data(NewData,#state{connection=Connection,buff=Buff0} = State0) -> %% xml does not accept a leading nl and some netconf server add a nl after %% each ?END_TAG, ignore them -append_wo_initial_nl(<<>>,NewData) -> NewData; -append_wo_initial_nl(<<"\n", Data/binary>>, NewData) -> - append_wo_initial_nl(Data, NewData); -append_wo_initial_nl(Data, NewData) -> - <<Data/binary, NewData/binary>>. +remove_initial_nl(<<"\n", Data/binary>>) -> + remove_initial_nl(Data); +remove_initial_nl(Data) -> + Data. handle_error(Reason, State) -> Pending1 = case State#state.pending of |