From ccb02e6d794003ccbaa5c37a17d0abb823c4b563 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Mon, 7 Jun 2010 16:04:35 +0100 Subject: Don't do another dirty_read to get a queue we already have. --- src/rabbit_channel.erl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index fcec3352..7d1f59ab 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -345,6 +345,18 @@ with_exclusive_access_or_die(QName, ReaderPid, F) -> Other end. +check_exclusive_access(Q = #amqqueue{exclusive_owner = Owner, + name = QName}, + ReaderPid) -> + case Owner of + none -> ok; + ReaderPid -> ok; + _ -> rabbit_misc:protocol_error( + resource_locked, + "cannot obtain exclusive access to locked ~s", + [rabbit_misc:rs(QName)]) + end. + expand_queue_name_shortcut(<<>>, #ch{ most_recently_declared_queue = <<>> }) -> rabbit_misc:protocol_error( not_allowed, "no previously declared queue", []); @@ -935,8 +947,8 @@ binding_action(Fun, ExchangeNameBin, QueueNameBin, RoutingKey, Arguments, check_read_permitted(ExchangeName, State), CheckExclusive = fun (_X, Q) -> - with_exclusive_access_or_die(Q#amqqueue.name, - ReaderPid, fun (_Q1)-> ok end) + check_exclusive_access(Q, ReaderPid), + fun (_Q1)-> ok end end, case Fun(ExchangeName, QueueName, ActualRoutingKey, Arguments, CheckExclusive) of -- cgit v1.2.1