diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2011-04-08 20:17:33 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2011-04-08 20:17:33 +0100 |
commit | 302343201c49049ca88f3133883b2ef1e7ec6249 (patch) | |
tree | d7904b23e61979b8a18cedd3b2fa62ab16eee815 | |
parent | 9579f96dd9507569d4e4f6576673137e3a329193 (diff) | |
parent | de9c5b5bd077da91ab3dd09b1654e4d0bd650452 (diff) | |
download | rabbitmq-server-302343201c49049ca88f3133883b2ef1e7ec6249.tar.gz |
merge default into bug24009
-rw-r--r-- | src/rabbit_binding.erl | 9 | ||||
-rw-r--r-- | src/rabbit_misc.erl | 26 |
2 files changed, 15 insertions, 20 deletions
diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl index e4827526..d7f55b54 100644 --- a/src/rabbit_binding.erl +++ b/src/rabbit_binding.erl @@ -105,15 +105,12 @@ recover(XNames, QNames) -> ok end, rabbit_durable_route), rabbit_misc:table_filter( - fun (#route{binding = B = #binding{destination = Dst = - #resource{kind = Kind}}}) -> - %% The check against rabbit_durable_route is in case it - %% disappeared between getting the list and here + fun (#route{binding = #binding{destination = Dst = + #resource{kind = Kind}}}) -> sets:is_element(Dst, case Kind of exchange -> XNameSet; queue -> QNameSet - end) andalso - mnesia:read({rabbit_semi_durable_route, B}) =/= [] + end) end, fun (R = #route{binding = B = #binding{source = Src}}, Tx) -> case Tx of diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 85e08615..cec10ff6 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -460,24 +460,22 @@ map_in_order(F, L) -> lists:reverse( lists:foldl(fun (E, Acc) -> [F(E) | Acc] end, [], L)). -%% Fold over each entry in a table, executing the pre-post-commit function in a -%% transaction. This is often far more efficient than wrapping a tx -%% around the lot. +%% Apply a pre-post-commit function to all entries in a table that +%% satisfy a predicate, and return those entries. %% %% We ignore entries that have been modified or removed. table_filter(Pred, PrePostCommitFun, TableName) -> lists:foldl( - fun (E, Acc) -> execute_mnesia_transaction( - fun () -> case mnesia:match_object(TableName, E, - read) of - [] -> false; - _ -> Pred(E) - end - end, - fun (false, _Tx) -> Acc; - (true, Tx) -> PrePostCommitFun(E, Tx), - [E | Acc] - end) + fun (E, Acc) -> + case execute_mnesia_transaction( + fun () -> mnesia:match_object(TableName, E, read) =/= [] + andalso Pred(E) end, + fun (false, _Tx) -> false; + (true, Tx) -> PrePostCommitFun(E, Tx), true + end) of + false -> Acc; + true -> [E | Acc] + end end, [], dirty_read_all(TableName)). dirty_read_all(TableName) -> |