summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-10-25 17:12:33 +0100
committerSimon MacMullen <simon@rabbitmq.com>2013-10-25 17:12:33 +0100
commit97980f20323416911ae3cb05a49b3bf3b42ebb99 (patch)
tree3156e2558068748bc5f7f80622caff604d7bcd1e /src
parentb4d32d99a0f8cc8e171885f8de6a404f882de1e3 (diff)
downloadrabbitmq-server-git-97980f20323416911ae3cb05a49b3bf3b42ebb99.tar.gz
Fairly nasty copy-and-paste based approach to making this more transactional. (Again, this time branched from stable correctly.)
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_policy.erl43
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;