diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2012-09-25 15:37:21 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-09-25 15:37:21 +0100 |
commit | f5e77c697a33161543c7505bc1a62ba60e4e4b0c (patch) | |
tree | 191ffca27095723b3a20f0670d8d5ed9d6f574c4 | |
parent | 55ba746dacd179f58482f4197fa375b55a3962f9 (diff) | |
download | rabbitmq-server-f5e77c697a33161543c7505bc1a62ba60e4e4b0c.tar.gz |
remove unnecessary calls to set_synchronised/2 in 'fetch'
-rw-r--r-- | src/rabbit_mirror_queue_slave.erl | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl index 1f6567e0..b28ff6e2 100644 --- a/src/rabbit_mirror_queue_slave.erl +++ b/src/rabbit_mirror_queue_slave.erl @@ -806,21 +806,17 @@ process_instruction({fetch, AckRequired, MsgId, Remaining}, State = #state { backing_queue = BQ, backing_queue_state = BQS }) -> QLen = BQ:len(BQS), - {State1, Delta} = - case QLen - 1 of - Remaining -> - {{#basic_message{id = MsgId}, _IsDelivered, - AckTag, Remaining}, BQS1} = BQ:fetch(AckRequired, BQS), - {maybe_store_ack(AckRequired, MsgId, AckTag, - State #state { backing_queue_state = BQS1 }), - 0}; + {ok, case QLen - 1 of + Remaining -> + {{#basic_message{id = MsgId}, _IsDelivered, + AckTag, Remaining}, BQS1} = BQ:fetch(AckRequired, BQS), + maybe_store_ack(AckRequired, MsgId, AckTag, + State #state { backing_queue_state = BQS1 }); + _ when QLen =< Remaining andalso AckRequired -> + State; _ when QLen =< Remaining -> - {State, case AckRequired of - true -> 0; - false -> -1 - end} - end, - {ok, set_synchronised(Delta, State1)}; + set_synchronised(-1, State) + end}; process_instruction({ack, MsgIds}, State = #state { backing_queue = BQ, backing_queue_state = BQS, |