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 | 66ecf4deade6b1a9edca4b546cedffc0568f3172 (patch) | |
| tree | d7904b23e61979b8a18cedd3b2fa62ab16eee815 /src | |
| parent | 824c9913d94154b5db8b117e93d509efd2a2d7d6 (diff) | |
| parent | 97b52fc91d35f5d7a2bb33b3ad7a8a8a5f8a0673 (diff) | |
| download | rabbitmq-server-git-66ecf4deade6b1a9edca4b546cedffc0568f3172.tar.gz | |
merge default into bug24009
Diffstat (limited to 'src')
| -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 e482752615..d7f55b54a6 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 85e08615c9..cec10ff609 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) -> |
