diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2010-06-07 16:04:35 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2010-06-07 16:04:35 +0100 |
commit | ccb02e6d794003ccbaa5c37a17d0abb823c4b563 (patch) | |
tree | 615eb438aef0c09ebc6f8985eb22abd172642e45 | |
parent | ded733191bfdc77f2438f68f04c3f342773d97f6 (diff) | |
download | rabbitmq-server-ccb02e6d794003ccbaa5c37a17d0abb823c4b563.tar.gz |
Don't do another dirty_read to get a queue we already have.
-rw-r--r-- | src/rabbit_channel.erl | 16 |
1 files 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 |