diff options
| author | Matthew Sackman <matthew@lshift.net> | 2009-11-26 17:48:21 +0000 |
|---|---|---|
| committer | Matthew Sackman <matthew@lshift.net> | 2009-11-26 17:48:21 +0000 |
| commit | 8aab49213274d25c00cf870f65aba95474f820e8 (patch) | |
| tree | 14d7ee580776a4359993c31ef719acd3a4752aaa | |
| parent | 3c22c6fda7163eb37eb0a595387d7827fc6b45c6 (diff) | |
| download | rabbitmq-server-git-8aab49213274d25c00cf870f65aba95474f820e8.tar.gz | |
Don't demonitor if we received a DOWN msg.
| -rw-r--r-- | src/rabbit_memory_monitor.erl | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/rabbit_memory_monitor.erl b/src/rabbit_memory_monitor.erl index 664e2348a1..43de768eb0 100644 --- a/src/rabbit_memory_monitor.erl +++ b/src/rabbit_memory_monitor.erl @@ -176,7 +176,7 @@ handle_cast(update, State) -> {noreply, internal_update(State)}; handle_cast({deregister, Pid}, State) -> - {noreply, internal_deregister(Pid, State)}; + {noreply, internal_deregister(Pid, true, State)}; handle_cast(stop, State) -> {stop, normal, State}; @@ -185,7 +185,7 @@ handle_cast(_Request, State) -> {noreply, State}. handle_info({'DOWN', _MRef, process, Pid, _Reason}, State) -> - {noreply, internal_deregister(Pid, State)}; + {noreply, internal_deregister(Pid, false, State)}; handle_info(_Info, State) -> {noreply, State}. @@ -208,13 +208,17 @@ zero_clamp(Sum) -> false -> Sum end. -internal_deregister(Pid, State = #state { queue_duration_sum = Sum, - queue_duration_count = Count, - queue_durations = Durations }) -> +internal_deregister(Pid, Demonitor, + State = #state { queue_duration_sum = Sum, + queue_duration_count = Count, + queue_durations = Durations }) -> case ets:lookup(Durations, Pid) of [] -> State; [#process { reported = PrevQueueDuration, monitor = MRef }] -> - true = erlang:demonitor(MRef), + true = case Demonitor of + true -> erlang:demonitor(MRef); + false -> true + end, {Sum1, Count1} = case PrevQueueDuration of infinity -> {Sum, Count}; |
