summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-04-08 18:08:39 +0100
committerSimon MacMullen <simon@rabbitmq.com>2014-04-08 18:08:39 +0100
commit8b9d9586c3fa13418a779b2202bbc3d4f1ed2164 (patch)
tree0dce435abb5e7ecc462bfa5066b36d3d1d2856b5
parent2f16bf43db30da94a1f3115bd19e12c3b4f196ea (diff)
downloadrabbitmq-server-8b9d9586c3fa13418a779b2202bbc3d4f1ed2164.tar.gz
Only allow cycles that contain reject.
-rw-r--r--src/rabbit_dead_letter.erl30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/rabbit_dead_letter.erl b/src/rabbit_dead_letter.erl
index 6aeace79..c087736b 100644
--- a/src/rabbit_dead_letter.erl
+++ b/src/rabbit_dead_letter.erl
@@ -25,7 +25,9 @@
-ifdef(use_specs).
--spec publish(rabbit_types:message(), atom(), rabbit_types:exchange(),
+-type reason() :: 'expired' | 'rejected' | 'maxlen'.
+
+-spec publish(rabbit_types:message(), reason(), rabbit_types:exchange(),
'undefined' | binary(), rabbit_amqqueue:name()) -> 'ok'.
-endif.
@@ -83,7 +85,10 @@ per_msg_ttl_header(#'P_basic'{expiration = Expiration}) ->
per_msg_ttl_header(_) ->
[].
-detect_cycles(expired, #basic_message{content = Content}, Queues) ->
+detect_cycles(rejected, _Msg, Queues) ->
+ {Queues, []};
+
+detect_cycles(_Reason, #basic_message{content = Content}, Queues) ->
#content{properties = #'P_basic'{headers = Headers}} =
rabbit_binary_parser:ensure_content_decoded(Content),
NoCycles = {Queues, []},
@@ -105,9 +110,7 @@ detect_cycles(expired, #basic_message{content = Content}, Queues) ->
_ ->
NoCycles
end
- end;
-detect_cycles(_Reason, _Msg, Queues) ->
- {Queues, []}.
+ end.
is_cycle(Queue, Deaths) ->
{Cycle, Rest} =
@@ -117,16 +120,17 @@ is_cycle(Queue, Deaths) ->
(_) ->
true
end, Deaths),
- %% Is there a cycle, and if so, is it entirely due to expiry?
+ %% Is there a cycle, and if so, is it "fully automatic", i.e. with
+ %% no reject in it?
case Rest of
[] -> false;
- [H|_] -> lists:all(
- fun ({table, D}) ->
- {longstr, <<"expired">>} =:=
- rabbit_misc:table_lookup(D, <<"reason">>);
- (_) ->
- false
- end, Cycle ++ [H])
+ [H|_] -> not lists:any(
+ fun ({table, D}) ->
+ {longstr, <<"rejected">>} =:=
+ rabbit_misc:table_lookup(D, <<"reason">>);
+ (_) ->
+ true
+ end, Cycle ++ [H])
end.
log_cycle_once(Queues) ->