Skip to content

Commit

Permalink
loop back to a previous request (TSUN-62)
Browse files Browse the repository at this point in the history
SVN Revision: 828
  • Loading branch information
nniclausse committed Apr 8, 2008
1 parent c3af9b0 commit cd0de81
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/ts_profile.hrl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
do = continue, %(continue | loop | stop) do = continue, %(continue | loop | stop)
sleep_loop, % in seconds sleep_loop, % in seconds
max_loop, max_loop,
loop_back,
max_restart max_restart
}). }).


Expand Down
6 changes: 3 additions & 3 deletions src/tsung/ts_search.erl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -184,23 +184,23 @@ setcount(#match{do=restart, max_restart=MaxRestart}, {_Count, MaxC}, Stats)->
ts_mon:add([{count, match_restart} | Stats]), ts_mon:add([{count, match_restart} | Stats]),
MaxC MaxC
end; end;
setcount(#match{do=loop,max_loop=MaxLoop,sleep_loop=Sleep},{Count,_MaxC},Stats)-> setcount(#match{do=loop,loop_back=Back,max_loop=MaxLoop,sleep_loop=Sleep},{Count,_MaxC},Stats)->
CurLoop = get(loop_count), CurLoop = get(loop_count),
?LOGF("Loop on (no)match ~p~n",[CurLoop], ?INFO), ?LOGF("Loop on (no)match ~p~n",[CurLoop], ?INFO),
ts_mon:add([{count, match_loop} | Stats]), ts_mon:add([{count, match_loop} | Stats]),
case CurLoop of case CurLoop of
undefined -> undefined ->
put(loop_count,1), put(loop_count,1),
timer:sleep(Sleep), timer:sleep(Sleep),
Count +1 ; Count +1 + Back ;
Val when Val >= MaxLoop -> Val when Val >= MaxLoop ->
?LOG("Max Loop reached, abort loop on request! ~n", ?WARN), ?LOG("Max Loop reached, abort loop on request! ~n", ?WARN),
put(loop_count, 0), put(loop_count, 0),
Count; Count;
Val -> Val ->
put(loop_count, Val +1), put(loop_count, Val +1),
timer:sleep(Sleep), timer:sleep(Sleep),
Count + 1 Count + 1 + Back
end; end;
setcount(#match{do=abort}, _, Stats) -> setcount(#match{do=abort}, _, Stats) ->
ts_mon:add([{count, match_stop} | Stats]), ts_mon:add([{count, match_stop} | Stats]),
Expand Down
4 changes: 2 additions & 2 deletions src/tsung_controller/ts_config.erl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@ parse(Element=#xmlElement{name=match,attributes=Attrs},
Do = getAttr(atom, Attrs, do, continue), Do = getAttr(atom, Attrs, do, continue),
When = getAttr(atom, Attrs, 'when', match), When = getAttr(atom, Attrs, 'when', match),
MaxLoop = getAttr(integer, Attrs, max_loop, 20), MaxLoop = getAttr(integer, Attrs, max_loop, 20),
LoopBack = getAttr(integer, Attrs, loop_back, 0),
MaxRestart = getAttr(integer, Attrs, max_restart, 3), MaxRestart = getAttr(integer, Attrs, max_restart, 3),
SleepLoop = getAttr(integer, Attrs, sleep_loop, 5), SleepLoop = getAttr(integer, Attrs, sleep_loop, 5),
ValRaw = getText(Element#xmlElement.content), ValRaw = getText(Element#xmlElement.content),
RegExp = ts_utils:clean_str(ValRaw), RegExp = ts_utils:clean_str(ValRaw),
NewMatch = #match{regexp=RegExp, do=Do,'when'=When,sleep_loop=SleepLoop * 1000, NewMatch = #match{regexp=RegExp, do=Do,'when'=When,sleep_loop=SleepLoop * 1000, loop_back=LoopBack, max_restart=MaxRestart, max_loop=MaxLoop },
max_restart=MaxRestart, max_loop=MaxLoop },


lists:foldl(fun parse/2, lists:foldl(fun parse/2,
Conf#config{ match=lists:append(Match, [NewMatch]) }, Conf#config{ match=lists:append(Match, [NewMatch]) },
Expand Down
1 change: 1 addition & 0 deletions tsung-1.0.dtd
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<!ATTLIST match <!ATTLIST match
do (continue|loop|abort|restart) "continue" do (continue|loop|abort|restart) "continue"
when (match|nomatch) "match" when (match|nomatch) "match"
loop_back NMTOKEN "0"
max_loop NMTOKEN "20" max_loop NMTOKEN "20"
max_restart NMTOKEN "3" max_restart NMTOKEN "3"
sleep_loop NMTOKEN "5" sleep_loop NMTOKEN "5"
Expand Down

0 comments on commit cd0de81

Please sign in to comment.