aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src/ct_netconfc.erl
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2015-12-09 11:48:08 +0100
committerSiri Hansen <[email protected]>2015-12-09 11:48:08 +0100
commit9d80569b209d37f711ca55c4673d8dd8fbf614fa (patch)
treeb4ca40f3a7dec82a0da440d15050432d38deb7c8 /lib/common_test/src/ct_netconfc.erl
parent8f91fc9576aa4abadf7e20e5aaabec1b37832145 (diff)
parent976214f8d738d4852348496df79f84264d899aba (diff)
downloadotp-9d80569b209d37f711ca55c4673d8dd8fbf614fa.tar.gz
otp-9d80569b209d37f711ca55c4673d8dd8fbf614fa.tar.bz2
otp-9d80569b209d37f711ca55c4673d8dd8fbf614fa.zip
Merge branch 'siri/ct_netconfc/slow-down/OTP-13007' into maint
* siri/ct_netconfc/slow-down/OTP-13007: Extended table_trans timer in order to handle big data on slow machines Don't log headings without content Speed up receive of many small packages Conflicts: lib/common_test/src/ct_conn_log_h.erl
Diffstat (limited to 'lib/common_test/src/ct_netconfc.erl')
-rw-r--r--lib/common_test/src/ct_netconfc.erl47
1 files changed, 33 insertions, 14 deletions
diff --git a/lib/common_test/src/ct_netconfc.erl b/lib/common_test/src/ct_netconfc.erl
index 05977e5649..6e3d1ab1d8 100644
--- a/lib/common_test/src/ct_netconfc.erl
+++ b/lib/common_test/src/ct_netconfc.erl
@@ -1374,11 +1374,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} ->
@@ -1400,11 +1407,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
@@ -1770,9 +1776,14 @@ format_data(How,Data) ->
do_format_data(raw,Data) ->
io_lib:format("~n~ts~n",[hide_password(Data)]);
do_format_data(pretty,Data) ->
- io_lib:format("~n~ts~n",[indent(Data)]);
+ maybe_io_lib_format(indent(Data));
do_format_data(html,Data) ->
- io_lib:format("~n~ts~n",[html_format(Data)]).
+ maybe_io_lib_format(html_format(Data)).
+
+maybe_io_lib_format(<<>>) ->
+ [];
+maybe_io_lib_format(String) ->
+ io_lib:format("~n~ts~n",[String]).
%%%-----------------------------------------------------------------
%%% Hide password elements from XML data
@@ -1811,13 +1822,21 @@ indent1("<?"++Rest1,Indent1) ->
Line++indent1(Rest2,Indent2);
indent1("</"++Rest1,Indent1) ->
%% Stop tag
- {Line,Rest2,Indent2} = indent_line1(Rest1,Indent1,[$/,$<]),
- "\n"++Line++indent1(Rest2,Indent2);
+ case indent_line1(Rest1,Indent1,[$/,$<]) of
+ {[],[],_} ->
+ [];
+ {Line,Rest2,Indent2} ->
+ "\n"++Line++indent1(Rest2,Indent2)
+ end;
indent1("<"++Rest1,Indent1) ->
%% Start- or empty tag
put(tag,get_tag(Rest1)),
- {Line,Rest2,Indent2} = indent_line(Rest1,Indent1,[$<]),
- "\n"++Line++indent1(Rest2,Indent2);
+ case indent_line(Rest1,Indent1,[$<]) of
+ {[],[],_} ->
+ [];
+ {Line,Rest2,Indent2} ->
+ "\n"++Line++indent1(Rest2,Indent2)
+ end;
indent1([H|T],Indent) ->
[H|indent1(T,Indent)];
indent1([],_Indent) ->