diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2015-03-13 12:52:10 +0000 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2015-03-13 12:52:10 +0000 |
| commit | be901c15d817f4e31b5563ca582e6ff6b39c78e7 (patch) | |
| tree | 727ed2b50c063970cde05434c13f58a611918eed /src | |
| parent | 17a5da8f085e4d4acb349fc41ceca0e923ac67d3 (diff) | |
| download | rabbitmq-server-git-be901c15d817f4e31b5563ca582e6ff6b39c78e7.tar.gz | |
Priority queue ram_duration/1 should be the minimum of sub-queues', not the sum. (References #67)
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_priority_queue.erl | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/rabbit_priority_queue.erl b/src/rabbit_priority_queue.erl index 1d9522f613..30e7c051fe 100644 --- a/src/rabbit_priority_queue.erl +++ b/src/rabbit_priority_queue.erl @@ -332,7 +332,7 @@ set_ram_duration_target(DurationTarget, ?passthrough1(set_ram_duration_target(DurationTarget, BQS)). ram_duration(State = #state{bq = BQ}) -> - fold_add2(fun (_P, BQSN) -> BQ:ram_duration(BQSN) end, State); + fold_min2(fun (_P, BQSN) -> BQ:ram_duration(BQSN) end, State); ram_duration(State = #passthrough{bq = BQ, bqs = BQS}) -> ?passthrough2(ram_duration(BQS)). @@ -459,6 +459,13 @@ fold_add2(Fun, State) -> {add_maybe_infinity(Res, Acc), BQSN1} end, 0, State). +%% Fold over results assuming results are numbers and we want the minimum +fold_min2(Fun, State) -> + fold2(fun (P, BQSN, Acc) -> + {Res, BQSN1} = Fun(P, BQSN), + {erlang:min(Res, Acc), BQSN1} + end, infinity, State). + %% Fold over results assuming results are lists and we want to append %% them, and also that we have some AckTags we want to pass in to each %% invocation. |
