summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2013-02-20 21:29:04 +0000
committerMatthias Radestock <matthias@rabbitmq.com>2013-02-20 21:29:04 +0000
commit94dd69341f9da0970111072c44ecff9e140c7926 (patch)
tree42276441af1a4eb0e68f08ba5fd5fd29e10fd2c0
parent9d115a8217adba13989efb9fb20660e6ea39241e (diff)
downloadrabbitmq-server-94dd69341f9da0970111072c44ecff9e140c7926.tar.gz
optimise possibly_unblock
when the channel is blocked there is no point going through the expensive consumer re-partitioning
-rw-r--r--src/rabbit_amqqueue_process.erl33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index 6de1d0a4..2b11c90d 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -639,21 +639,24 @@ possibly_unblock(State, ChPid, Update) ->
end.
possibly_unblock(State, C = #cr{limiter = Limiter}) ->
- IsChBlocked = is_ch_blocked(C),
- case lists:partition(
- fun({_ChPid, #consumer{tag = CTag}}) ->
- IsChBlocked orelse
- rabbit_limiter:is_consumer_blocked(Limiter, CTag)
- end, queue:to_list(C#cr.blocked_consumers)) of
- {_, []} ->
- update_ch_record(C),
- State;
- {Blocked, Unblocked} ->
- BlockedQ = queue:from_list(Blocked),
- UnblockedQ = queue:from_list(Unblocked),
- update_ch_record(C#cr{blocked_consumers = BlockedQ}),
- AC1 = queue:join(State#q.active_consumers, UnblockedQ),
- run_message_queue(State#q{active_consumers = AC1})
+ case is_ch_blocked(C) of
+ true -> update_ch_record(C),
+ State;
+ false -> case lists:partition(
+ fun({_ChPid, #consumer{tag = CTag}}) ->
+ rabbit_limiter:is_consumer_blocked(
+ Limiter, CTag)
+ end, queue:to_list(C#cr.blocked_consumers)) of
+ {_, []} ->
+ update_ch_record(C),
+ State;
+ {Blocked, Unblocked} ->
+ BlockedQ = queue:from_list(Blocked),
+ UnblockedQ = queue:from_list(Unblocked),
+ update_ch_record(C#cr{blocked_consumers = BlockedQ}),
+ AC1 = queue:join(State#q.active_consumers, UnblockedQ),
+ run_message_queue(State#q{active_consumers = AC1})
+ end
end.
should_auto_delete(#q{q = #amqqueue{auto_delete = false}}) -> false;