summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2010-11-10 16:55:53 +0000
committerMatthew Sackman <matthew@rabbitmq.com>2010-11-10 16:55:53 +0000
commit6e7d448b39a9caef8659909c063ff6082b7e513e (patch)
treeb5644ba2e468728c6ea459034c57f9fd19ab7d0c
parent34ba59a6d6c1cbea4d27cf5890b140dd176f3b6e (diff)
downloadrabbitmq-server-git-6e7d448b39a9caef8659909c063ff6082b7e513e.tar.gz
Minor moving about and cosmetics
-rw-r--r--src/rabbit_amqqueue_process.erl24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index b55f927439..fdb5134ce8 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -315,23 +315,23 @@ ch_record(ChPid) ->
store_ch_record(C = #cr{ch_pid = ChPid}) ->
put({ch, ChPid}, C).
-%% If the channel record we're considering submitting to the process
-%% dictionary has no consumers, has no pending acks, and doesn't have
-%% a transaction, we should delete its record rather than storing it.
-%% If the ch record was stored, this function returns true; otherwise,
-%% the ch record is erased and this function returns false.
maybe_store_ch_record(C = #cr{consumer_count = ConsumerCount,
limiter_pid = LimiterPid,
acktags = ChAckTags,
txn = Txn}) ->
case {sets:size(ChAckTags), ConsumerCount, Txn} of
- {0, 0, none} -> demonitor_and_erase_ch_record(C),
+ {0, 0, none} -> erase_ch_record(C),
ok = rabbit_limiter:unregister(LimiterPid, self()),
false;
_ -> store_ch_record(C),
true
end.
+erase_ch_record(#cr{ch_pid = ChPid,
+ monitor_ref = MonitorRef}) ->
+ erlang:demonitor(MonitorRef),
+ erase({ch, ChPid}).
+
all_ch_record() ->
[C || {{ch, _}, C} <- get()].
@@ -496,7 +496,7 @@ possibly_unblock(State, ChPid, Update) ->
State;
C ->
NewC = Update(C),
- true = maybe_store_ch_record(NewC),
+ maybe_store_ch_record(NewC),
case ch_record_state_transition(C, NewC) of
ok -> State;
unblock -> {NewBlockedConsumers, NewActiveConsumers} =
@@ -518,7 +518,7 @@ handle_ch_down(DownPid, State = #q{exclusive_consumer = Holder}) ->
not_found ->
{ok, State};
C = #cr{ch_pid = ChPid, txn = Txn, acktags = ChAckTags} ->
- demonitor_and_erase_ch_record(C),
+ erase_ch_record(C),
State1 = State#q{
exclusive_consumer = case Holder of
{ChPid, _} -> none;
@@ -843,8 +843,7 @@ handle_call({basic_cancel, ChPid, ConsumerTag, OkMsg}, _From,
ok = maybe_send_reply(ChPid, OkMsg),
reply(ok, State);
C = #cr{consumer_count = ConsumerCount} ->
- C1 = C#cr{consumer_count = ConsumerCount-1},
- maybe_store_ch_record(C1),
+ maybe_store_ch_record(C#cr{consumer_count = ConsumerCount-1}),
ok = maybe_send_reply(ChPid, OkMsg),
NewState =
State#q{exclusive_consumer = cancel_holder(ChPid,
@@ -1049,8 +1048,3 @@ handle_pre_hibernate(State = #q{backing_queue = BQ,
State1 = State#q{stats_timer = rabbit_event:stop_stats_timer(StatsTimer),
backing_queue_state = BQS2},
{hibernate, stop_rate_timer(State1)}.
-
-demonitor_and_erase_ch_record(#cr{ch_pid = ChPid,
- monitor_ref = MonitorRef}) ->
- erlang:demonitor(MonitorRef),
- erase({ch, ChPid}).