summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@lshift.net>2010-02-11 16:45:54 +0000
committerMatthias Radestock <matthias@lshift.net>2010-02-11 16:45:54 +0000
commitf6e7c07cd864666a42768447dbdde14452ed5b27 (patch)
tree2ba1c88f45a0c47141262111700c173a5608f3a2
parent748011f6e985c117062e7a3e47eacc1a590b6a1b (diff)
downloadrabbitmq-server-f6e7c07cd864666a42768447dbdde14452ed5b27.tar.gz
minor optimisation
when handling channel closure in the queue process, don't do any unnecessary work when we end up auto-deleting the queue. Specifically we don't rollback any transaction or attempt to deliver any messages. The formmer happens in the termination code anyway. The latter is a change in behaviour, but one that is permitted by the spec, and arguably deleting the queue as quickly as possible. The bug21673 branch already has changes along similar lines.
-rw-r--r--src/rabbit_amqqueue_process.erl41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index 6a679aaa..f345b4c5 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -325,27 +325,26 @@ handle_ch_down(DownPid, State = #q{exclusive_consumer = Holder}) ->
unacked_messages = UAM} ->
erlang:demonitor(MonitorRef),
erase({ch, ChPid}),
- case Txn of
- none -> ok;
- _ -> ok = rollback_work(Txn, qname(State)),
- erase_tx(Txn)
- end,
- NewState =
- deliver_or_enqueue_n(
- [{Message, true} ||
- {_Messsage_id, Message} <- dict:to_list(UAM)],
- State#q{
- exclusive_consumer = case Holder of
- {ChPid, _} -> none;
- Other -> Other
- end,
- active_consumers = remove_consumers(
- ChPid, State#q.active_consumers),
- blocked_consumers = remove_consumers(
- ChPid, State#q.blocked_consumers)}),
- case should_auto_delete(NewState) of
- false -> {ok, NewState};
- true -> {stop, NewState}
+ State1 = State#q{
+ exclusive_consumer = case Holder of
+ {ChPid, _} -> none;
+ Other -> Other
+ end,
+ active_consumers = remove_consumers(
+ ChPid, State#q.active_consumers),
+ blocked_consumers = remove_consumers(
+ ChPid, State#q.blocked_consumers)},
+ case should_auto_delete(State1) of
+ true -> {stop, State1};
+ false -> case Txn of
+ none -> ok;
+ _ -> ok = rollback_work(Txn, qname(State1)),
+ erase_tx(Txn)
+ end,
+ {ok, deliver_or_enqueue_n(
+ [{Message, true} ||
+ {_MsgId, Message} <- dict:to_list(UAM)],
+ State1)}
end
end.