summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rabbit_router.erl17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/rabbit_router.erl b/src/rabbit_router.erl
index 1f3017fa07..aaa2f1e170 100644
--- a/src/rabbit_router.erl
+++ b/src/rabbit_router.erl
@@ -36,17 +36,14 @@
%%----------------------------------------------------------------------------
-%% TODO: Maybe this should be handled by a cursor instead.
-%% TODO: This causes a full scan for each entry with the same source
+%% No need to call mnesia:dirty_select/2 (cf. note below), let alone go
+%% through qlc because query is so simple !
match_bindings(SrcName, Match) ->
- Query = qlc:q([DestinationName ||
- #route{binding = Binding = #binding{
- source = SrcName1,
- destination = DestinationName}} <-
- mnesia:table(rabbit_route),
- SrcName == SrcName1,
- Match(Binding)]),
- mnesia:async_dirty(fun qlc:e/1, [Query]).
+ MatchHead = #route{binding = #binding{source = SrcName,
+ _ = '_'}},
+ Routes = ets:select(rabbit_route, [{MatchHead, [], [['$_']]}]),
+ [ Dest || [#route{binding = Binding = #binding{destination = Dest}}] <-
+ Routes, Match(Binding)].
match_routing_key(SrcName, [RoutingKey]) ->
find_routes(#route{binding = #binding{source = SrcName,