diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2010-07-15 08:21:54 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-07-15 08:21:54 +0100 |
| commit | 2c94632fd5e0e370f16d8fc4a445d63f27e40277 (patch) | |
| tree | 80b011c64ba31ab20c53c6cbc586c54c584d91c0 /src | |
| parent | bf34fd55f2159c524a37159a7a3d3cd1540f8f93 (diff) | |
| download | rabbitmq-server-git-2c94632fd5e0e370f16d8fc4a445d63f27e40277.tar.gz | |
simplify remove_pending_ack
The pending_ack dict should always be empty at the end. Previously we
kept the ack records of persistent messages when KeepPersistent=true.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_variable_queue.erl | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl index 84db32466e..04dcf88d0c 100644 --- a/src/rabbit_variable_queue.erl +++ b/src/rabbit_variable_queue.erl @@ -1052,20 +1052,15 @@ record_pending_ack(#msg_status { guid = Guid, seq_id = SeqId, remove_pending_ack(KeepPersistent, State = #vqstate { pending_ack = PA, index_state = IndexState }) -> - {{SeqIds, GuidsByStore}, PA1} = - dict:fold( - fun (SeqId, {IsPersistent, Guid}, {Acc, PA2}) -> - {accumulate_ack(SeqId, IsPersistent, Guid, Acc), - case KeepPersistent andalso IsPersistent of - true -> PA2; - false -> dict:erase(SeqId, PA2) - end}; - (SeqId, #msg_status {}, {Acc, PA2}) -> - {Acc, dict:erase(SeqId, PA2)} - end, {{[], dict:new()}, PA}, PA), + {SeqIds, GuidsByStore} = + dict:fold(fun (SeqId, {IsPersistent, Guid}, Acc) -> + accumulate_ack(SeqId, IsPersistent, Guid, Acc); + (_SeqId, #msg_status {}, Acc) -> + Acc + end, {[], dict:new()}, PA), + State1 = State #vqstate { pending_ack = dict:new() }, case KeepPersistent of - true -> State1 = State #vqstate { pending_ack = PA1 }, - case dict:find(?TRANSIENT_MSG_STORE, GuidsByStore) of + true -> case dict:find(?TRANSIENT_MSG_STORE, GuidsByStore) of error -> State1; {ok, Guids} -> ok = rabbit_msg_store:remove( ?TRANSIENT_MSG_STORE, Guids), @@ -1075,8 +1070,7 @@ remove_pending_ack(KeepPersistent, ok = dict:fold(fun (MsgStore, Guids, ok) -> rabbit_msg_store:remove(MsgStore, Guids) end, ok, GuidsByStore), - State #vqstate { pending_ack = dict:new(), - index_state = IndexState1 } + State1 #vqstate { index_state = IndexState1 } end. ack(_MsgStoreFun, _Fun, [], State) -> |
