From 8e797c8b0deac0bc9b1c2fe8195cfd7ea3bc0362 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Fri, 16 Sep 2011 15:05:14 +0100 Subject: some tweaks for sake of symmetry ...and some cosmetics --- src/rabbit_channel.erl | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 10697123..cee8d761 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -1126,14 +1126,6 @@ handle_method(_MethodRecord, _Content, _State) -> %%---------------------------------------------------------------------------- -monitor_queue(QPid, State = #ch{queue_monitors = QMons}) -> - case (not dict:is_key(QPid, QMons) andalso - queue_monitor_needed(QPid, State)) of - true -> MRef = erlang:monitor(process, QPid), - State#ch{queue_monitors = dict:store(QPid, MRef, QMons)}; - false -> State - end. - consumer_monitor(ConsumerTag, State = #ch{consumer_mapping = ConsumerMapping, queue_consumers = QCons, @@ -1153,15 +1145,20 @@ consumer_monitor(ConsumerTag, State end. +monitor_queue(QPid, State = #ch{queue_monitors = QMons}) -> + case (not dict:is_key(QPid, QMons) andalso + queue_monitor_needed(QPid, State)) of + true -> MRef = erlang:monitor(process, QPid), + State#ch{queue_monitors = dict:store(QPid, MRef, QMons)}; + false -> State + end. + demonitor_queue(QPid, State = #ch{queue_monitors = QMons}) -> - case dict:find(QPid, QMons) of - error -> State; - {ok, MRef} -> case queue_monitor_needed(QPid, State) of - false -> true = erlang:demonitor(MRef), - State#ch{queue_monitors = - dict:erase(QPid, QMons)}; - true -> State - end + case (dict:is_key(QPid, QMons) andalso + not queue_monitor_needed(QPid, State)) of + true -> true = erlang:demonitor(dict:fetch(QPid, QMons)), + State#ch{queue_monitors = dict:erase(QPid, QMons)}; + false -> State end. queue_monitor_needed(QPid, #ch{stats_timer = StatsTimer, -- cgit v1.2.1