summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2010-05-27 13:44:08 +0100
committerMatthew Sackman <matthew@rabbitmq.com>2010-05-27 13:44:08 +0100
commit329f0874d2eb7c92600fa7ac759095a3676638bf (patch)
treea0754e03b43c5b5bfb18cf8aed2cd2ccafbc8b7d
parent7e218ebbe9b8014082fda807049b9bab795b2abe (diff)
downloadrabbitmq-server-bug21915.tar.gz
Cosmeticsbug21915
-rw-r--r--src/rabbit_amqqueue.erl4
-rw-r--r--src/rabbit_channel.erl54
2 files changed, 25 insertions, 33 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index 1210e115..483b5a93 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -319,7 +319,7 @@ flush_all(QPids, ChPid) ->
delegate:invoke_no_result(
QPids, fun (QPid) -> gen_server2:cast(QPid, {flush, ChPid}) end).
-internal_delete2(QueueName) ->
+internal_delete1(QueueName) ->
ok = mnesia:delete({rabbit_queue, QueueName}),
ok = mnesia:delete({rabbit_durable_queue, QueueName}),
%% we want to execute some things, as
@@ -333,7 +333,7 @@ internal_delete(QueueName) ->
fun () ->
case mnesia:wread({rabbit_queue, QueueName}) of
[] -> {error, not_found};
- [_] -> internal_delete2(QueueName)
+ [_] -> internal_delete1(QueueName)
end
end) of
Err = {error, _} -> Err;
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 2751f5b7..f23b6d9c 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -299,17 +299,16 @@ check_read_permitted(Resource, #ch{ username = Username}) ->
check_resource_access(Username, Resource, read).
with_exclusive_access_or_die(QName, ReaderPid, F) ->
- F2 = fun(Q) ->
- case Q of
- #amqqueue{exclusive_owner = none} ->
- F(Q);
- #amqqueue{exclusive_owner = ReaderPid} ->
- F(Q);
- _ ->
- {error, wrong_exclusive_owner}
- end
- end,
- case rabbit_amqqueue:with_or_die(QName, F2) of
+ case rabbit_amqqueue:with_or_die(
+ QName, fun(Q) -> case Q of
+ #amqqueue{exclusive_owner = none} ->
+ F(Q);
+ #amqqueue{exclusive_owner = ReaderPid} ->
+ F(Q);
+ _ ->
+ {error, wrong_exclusive_owner}
+ end
+ end) of
{error, wrong_exclusive_owner} ->
rabbit_misc:protocol_error(
resource_locked,
@@ -703,19 +702,17 @@ handle_method(#'queue.declare'{queue = QueueNameBin,
%% We use this in both branches, because queue_declare may yet return an
%% existing queue.
Finish =
- fun(Q) ->
+ fun(Q = #amqqueue{name = QueueName}) ->
case Q of
%% "equivalent" rule. NB: we don't pay attention to
%% anything in the arguments table, so for the sake of the
%% "equivalent" rule, all tables of arguments are
%% semantically equivalant.
- Matched = #amqqueue{name = QueueName,
- exclusive_owner = Owner
- } ->
+ #amqqueue{exclusive_owner = Owner} ->
check_configure_permitted(QueueName, State),
- Matched;
+ Q;
%% exclusivity trumps non-equivalence arbitrarily
- #amqqueue{name = QueueName} ->
+ #amqqueue{} ->
rabbit_misc:protocol_error(
resource_locked,
"cannot obtain exclusive access to locked ~s",
@@ -732,20 +729,18 @@ handle_method(#'queue.declare'{queue = QueueNameBin,
Other -> check_name('queue', Other)
end,
QueueName = rabbit_misc:r(VHostPath, queue, ActualNameBin),
- check_configure_permitted(QueueName, State),
Finish(rabbit_amqqueue:declare(QueueName, Durable, AutoDelete,
Args, Owner));
- Other = #amqqueue{name = QueueName} ->
- check_configure_permitted(QueueName, State),
+ #amqqueue{} = Other ->
Other
end,
return_queue_declare_ok(State, NoWait, Q);
-handle_method(#'queue.declare'{queue = QueueNameBin,
+handle_method(#'queue.declare'{queue = QueueNameBin,
passive = true,
- nowait = NoWait},
- _, State = #ch{ virtual_host = VHostPath,
- reader_pid = ReaderPid }) ->
+ nowait = NoWait},
+ _, State = #ch{virtual_host = VHostPath,
+ reader_pid = ReaderPid}) ->
QueueName = rabbit_misc:r(VHostPath, queue, QueueNameBin),
check_configure_permitted(QueueName, State),
Q = with_exclusive_access_or_die(QueueName, ReaderPid, fun(Q) -> Q end),
@@ -754,16 +749,13 @@ handle_method(#'queue.declare'{queue = QueueNameBin,
handle_method(#'queue.delete'{queue = QueueNameBin,
if_unused = IfUnused,
if_empty = IfEmpty,
- nowait = NoWait
- },
- _, State = #ch{ reader_pid = ReaderPid }) ->
+ nowait = NoWait},
+ _, State = #ch{reader_pid = ReaderPid}) ->
QueueName = expand_queue_name_shortcut(QueueNameBin, State),
check_configure_permitted(QueueName, State),
case with_exclusive_access_or_die(
QueueName, ReaderPid,
- fun (Q) ->
- rabbit_amqqueue:delete(Q, IfUnused, IfEmpty)
- end) of
+ fun (Q) -> rabbit_amqqueue:delete(Q, IfUnused, IfEmpty) end) of
{error, in_use} ->
rabbit_misc:protocol_error(
precondition_failed, "~s in use", [rabbit_misc:rs(QueueName)]);
@@ -795,7 +787,7 @@ handle_method(#'queue.unbind'{queue = QueueNameBin,
handle_method(#'queue.purge'{queue = QueueNameBin,
nowait = NoWait},
- _, State = #ch{ reader_pid = ReaderPid }) ->
+ _, State = #ch{reader_pid = ReaderPid}) ->
QueueName = expand_queue_name_shortcut(QueueNameBin, State),
check_read_permitted(QueueName, State),
{ok, PurgedMessageCount} = with_exclusive_access_or_die(