summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Klishin <mklishin@pivotal.io>2019-02-16 15:10:20 +0300
committerMichael Klishin <mklishin@pivotal.io>2019-02-16 15:10:20 +0300
commit51569c4dd01ecf68cd74b1ba87f780dbf2b4dc77 (patch)
treeb35ebc8a441264f19c464cd0539d20c9395479b5
parentbdf3cfb76205fef2b6208b17cc81f3b86d8b1db6 (diff)
downloadrabbitmq-server-git-51569c4dd01ecf68cd74b1ba87f780dbf2b4dc77.tar.gz
Filter duplicate default exchange binding in `rabbit_binding:list_for_destination/1`
Follow-up to #1721. Even though the default exchange bindings are deleted at schema migration time, this filtering improves backwards compatibility for mixed version clusters.
-rw-r--r--src/rabbit_binding.erl11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl
index ab3bc6c819..918b5c3ce8 100644
--- a/src/rabbit_binding.erl
+++ b/src/rabbit_binding.erl
@@ -275,9 +275,8 @@ list_for_source(SrcName) ->
-spec list_for_destination
(rabbit_types:binding_destination()) -> bindings().
-list_for_destination(DstName) ->
- implicit_for_destination(DstName) ++
- mnesia:async_dirty(
+list_for_destination(DstName = #resource{virtual_host = VHostPath}) ->
+ AllBindings = mnesia:async_dirty(
fun() ->
Route = #route{binding = #binding{destination = DstName,
_ = '_'}},
@@ -285,7 +284,11 @@ list_for_destination(DstName) ->
#reverse_route{reverse_binding = B} <-
mnesia:match_object(rabbit_reverse_route,
reverse_route(Route), read)]
- end).
+ end),
+ Filtered = lists:filter(fun(#binding{source = S}) ->
+ S =/= ?DEFAULT_EXCHANGE(VHostPath)
+ end, AllBindings),
+ implicit_for_destination(DstName) ++ Filtered.
implicit_bindings(VHostPath) ->
DstQueues = rabbit_amqqueue:list_names(VHostPath),