diff options
| author | Emile Joubert <emile@rabbitmq.com> | 2012-01-05 13:34:34 +0000 |
|---|---|---|
| committer | Emile Joubert <emile@rabbitmq.com> | 2012-01-05 13:34:34 +0000 |
| commit | 96994162eef383c82b7f9e20e9d4af479699bee8 (patch) | |
| tree | c12e37f0b3f57b9a61dee0652ede445950431d97 /src | |
| parent | a3b1d5bd212786c38c9a957c071d7e7eb23f686b (diff) | |
| parent | 50c0c2366998c452d6be39ec044b629ef314ad07 (diff) | |
| download | rabbitmq-server-git-96994162eef383c82b7f9e20e9d4af479699bee8.tar.gz | |
Merged bug24659 into default (2)
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_memory_monitor.erl | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/src/rabbit_memory_monitor.erl b/src/rabbit_memory_monitor.erl index 02f3158f3b..c25a177b06 100644 --- a/src/rabbit_memory_monitor.erl +++ b/src/rabbit_memory_monitor.erl @@ -178,11 +178,8 @@ code_change(_OldVsn, State, _Extra) -> %% Internal functions %%---------------------------------------------------------------------------- -zero_clamp(Sum) -> - case Sum < ?EPSILON of - true -> 0.0; - false -> Sum - end. +zero_clamp(Sum) when Sum < ?EPSILON -> 0.0; +zero_clamp(Sum) -> Sum. internal_deregister(Pid, Demonitor, State = #state { queue_duration_sum = Sum, @@ -240,26 +237,21 @@ internal_update(State = #state { queue_durations = Durations, fun (Proc = #process { reported = QueueDuration, sent = PrevSendDuration, callback = {M, F, A} }, true) -> - case (case {QueueDuration, PrevSendDuration} of - {infinity, infinity} -> - true; - {infinity, D} -> - DesiredDurationAvg1 < D; - {D, infinity} -> - DesiredDurationAvg1 < D; - {D1, D2} -> - DesiredDurationAvg1 < - lists:min([D1,D2]) - end) of - true -> - ok = erlang:apply( - M, F, A ++ [DesiredDurationAvg1]), - ets:insert( - Durations, - Proc #process {sent = DesiredDurationAvg1}); - false -> - true + case should_send(QueueDuration, PrevSendDuration, + DesiredDurationAvg1) of + true -> ok = erlang:apply( + M, F, A ++ [DesiredDurationAvg1]), + ets:insert( + Durations, + Proc #process { + sent = DesiredDurationAvg1}); + false -> true end end, true, Durations) end, State1. + +should_send(infinity, infinity, _) -> true; +should_send(infinity, D, DD) -> DD < D; +should_send(D, infinity, DD) -> DD < D; +should_send(D1, D2, DD) -> DD < lists:min([D1, D2]). |
