diff options
author | Matthew Sackman <matthew@rabbitmq.com> | 2011-09-15 15:29:12 +0100 |
---|---|---|
committer | Matthew Sackman <matthew@rabbitmq.com> | 2011-09-15 15:29:12 +0100 |
commit | 2654a33573dcced989eb45b60b912e62e9d66b0d (patch) | |
tree | 456cb4e05ac03492e5b4117838a6736b13a346f1 /src/rabbit_binding.erl | |
parent | bb416385996c9cfcb5bd7c7c017c13d366703e5a (diff) | |
download | rabbitmq-server-2654a33573dcced989eb45b60b912e62e9d66b0d.tar.gz |
Rework binding recovery
Diffstat (limited to 'src/rabbit_binding.erl')
-rw-r--r-- | src/rabbit_binding.erl | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl index 205d5bba..d8190586 100644 --- a/src/rabbit_binding.erl +++ b/src/rabbit_binding.erl @@ -115,20 +115,27 @@ recover(XNames, QNames) -> 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). + case sets:is_element(Dst, ToRecover) of + true -> {ok, X} = rabbit_exchange:lookup(Src), + rabbit_misc:execute_mnesia_transaction( + fun () -> + case [] =/= mnesia:match_object( + rabbit_semi_durable_route, R, read) 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); + false -> ok + end. exists(Binding) -> binding_action( |