summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2011-07-07 13:47:12 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2011-07-07 13:47:12 +0100
commit0019857ceb17518e355677398cbaaa57b1e377d9 (patch)
treeb987666b0f0438ff659f6c3b9d2c3246226ac2ea
parent213923a4e3ddc67d5649850d967074f33ccf0aeb (diff)
parent27a4d83849a745a6eb6432f1b7bae9c2299fefca (diff)
downloadrabbitmq-server-0019857ceb17518e355677398cbaaa57b1e377d9.tar.gz
merge bug24244 into default
-rw-r--r--src/rabbit_binding.erl46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl
index 5873537c..205d5bba 100644
--- a/src/rabbit_binding.erl
+++ b/src/rabbit_binding.erl
@@ -94,8 +94,6 @@
routing_key, arguments]).
recover(XNames, QNames) ->
- XNameSet = sets:from_list(XNames),
- QNameSet = sets:from_list(QNames),
rabbit_misc:table_filter(
fun (Route) ->
mnesia:read({rabbit_semi_durable_route, Route}) =:= []
@@ -105,27 +103,33 @@ recover(XNames, QNames) ->
(_Route, false) ->
ok
end, rabbit_durable_route),
- rabbit_misc:table_filter(
- fun (#route{binding = #binding{destination = Dst =
- #resource{kind = Kind}}}) ->
- sets:is_element(Dst, case Kind of
- exchange -> XNameSet;
- queue -> QNameSet
- end)
- end,
- fun (R = #route{binding = B = #binding{source = Src}}, Tx) ->
- {ok, X} = rabbit_exchange:lookup(Src),
- Serial = case Tx of
- true -> ok = sync_transient_route(
- R, fun mnesia:write/3),
- transaction;
- false -> rabbit_exchange:serial(X)
- end,
- rabbit_exchange:callback(X, add_binding, [Serial, X, B])
- end,
- rabbit_semi_durable_route),
+ XNameSet = sets:from_list(XNames),
+ QNameSet = sets:from_list(QNames),
+ SelectSet = fun (#resource{kind = exchange}) -> XNameSet;
+ (#resource{kind = queue}) -> QNameSet
+ end,
+ [recover_semi_durable_route(R, SelectSet(Dst)) ||
+ R = #route{binding = #binding{destination = Dst}} <-
+ rabbit_misc:dirty_read_all(rabbit_semi_durable_route)],
ok.
+recover_semi_durable_route(R = #route{binding = B}, ToRecover) ->
+ #binding{source = Src, destination = Dst} = B,
+ {ok, X} = rabbit_exchange:lookup(Src),
+ rabbit_misc:execute_mnesia_transaction(
+ fun () ->
+ Rs = mnesia:match_object(rabbit_semi_durable_route, R, read),
+ case Rs =/= [] andalso sets:is_element(Dst, ToRecover) of
+ false -> no_recover;
+ true -> ok = sync_transient_route(R, fun mnesia:write/3),
+ rabbit_exchange:serial(X)
+ end
+ end,
+ fun (no_recover, _) -> ok;
+ (_Serial, true) -> x_callback(transaction, X, add_binding, B);
+ (Serial, false) -> x_callback(Serial, X, add_binding, B)
+ end).
+
exists(Binding) ->
binding_action(
Binding, fun (_Src, _Dst, B) ->