diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_policy.erl | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/src/rabbit_policy.erl b/src/rabbit_policy.erl index 91ca88dd07..924737f61c 100644 --- a/src/rabbit_policy.erl +++ b/src/rabbit_policy.erl @@ -156,18 +156,45 @@ notify_clear(VHost, <<"policy">>, _Name) -> %%---------------------------------------------------------------------------- update_policies(VHost) -> - Policies = list(VHost), - {Xs, Qs} = rabbit_misc:execute_mnesia_transaction( - fun() -> - {[update_exchange(X, Policies) || - X <- rabbit_exchange:list(VHost)], - [update_queue(Q, Policies) || - Q <- rabbit_amqqueue:list(VHost)]} - end), + F = fun() -> + Policies = list_tx(VHost), + Xs = mnesia:match_object( + rabbit_exchange, + #exchange{name = rabbit_misc:r(VHost, exchange), + _ = '_'}, + read), + Qs = mnesia:match_object( + rabbit_queue, + #amqqueue{name = rabbit_misc:r(VHost, queue), + _ = '_'}, + read), + {[update_exchange(X, Policies) || X <- Xs], + [update_queue(Q, Policies) || Q <- Qs]} + end, + {Xs, Qs} = rabbit_misc:execute_mnesia_transaction(F), [catch notify(X) || X <- Xs], [catch notify(Q) || Q <- Qs], ok. +list_tx(VHost) -> + [p(P, fun ident/1) || P <- list_p(VHost, <<"policy">>)]. + +list_p(VHost, Component) -> + case VHost of + '_' -> ok; + _ -> rabbit_vhost:assert(VHost) + end, + Match = #runtime_parameters{key = {VHost, Component, '_'}, _ = '_'}, + [p_p(P) || #runtime_parameters{key = {_VHost, Comp, _Name}} = P <- + mnesia:match_object(rabbit_runtime_parameters, Match, read), + Comp =/= <<"policy">> orelse Component =:= <<"policy">>]. + +p_p(#runtime_parameters{key = {VHost, Component, Name}, value = Value}) -> + [{vhost, VHost}, + {component, Component}, + {name, Name}, + {value, Value}]. + update_exchange(X = #exchange{name = XName, policy = OldPolicy}, Policies) -> case match(XName, Policies) of OldPolicy -> no_change; |
