diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2012-01-09 15:15:23 +0000 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2012-01-09 15:15:23 +0000 |
| commit | 5a8226b644e71770e049517e7ecd143eabe8afae (patch) | |
| tree | 8124d19b37ebfedc03f6e46a23ab4a4177c16da8 /src | |
| parent | 2302e6bba1689f6dc72998ea945c3fff373af5ff (diff) | |
| parent | 96994162eef383c82b7f9e20e9d4af479699bee8 (diff) | |
| download | rabbitmq-server-git-5a8226b644e71770e049517e7ecd143eabe8afae.tar.gz | |
Merge bug24649.
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]). |
