diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2012-09-25 18:07:03 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2012-09-25 18:07:03 +0100 |
commit | 6cdf3e7e0a198f969808268f396ebb0a98440068 (patch) | |
tree | c7ed80e0a134a07c787d9534cfaf6de8a4e75b6f | |
parent | 813d9ab83e883034e4270c1b54606895866166bd (diff) | |
download | rabbitmq-server-6cdf3e7e0a198f969808268f396ebb0a98440068.tar.gz |
Refactor which I find clearer. Yes "DeltaChange". But it's a delta of a delta, and "deltadelta" sounds silly.
-rw-r--r-- | src/rabbit_mirror_queue_slave.erl | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl index f30264e1..4d53bd1b 100644 --- a/src/rabbit_mirror_queue_slave.erl +++ b/src/rabbit_mirror_queue_slave.erl @@ -887,14 +887,16 @@ maybe_store_ack(true, MsgId, AckTag, State = #state { msg_id_ack = MA, State #state { msg_id_ack = dict:store(MsgId, {Num, AckTag}, MA), ack_num = Num + 1 }. -set_synchronised(_Delta, State = #state { depth_delta = undefined }) -> +set_synchronised(_DeltaChange, State = #state { depth_delta = undefined }) -> State; -set_synchronised(Delta, State = #state { depth_delta = D }) -> - case D + Delta of - 0 when D == 0 -> State; - 0 when D =/= 0 -> ok = record_synchronised(State#state.q), - State #state { depth_delta = 0 }; - N when D =/= 0 andalso N > 0 -> State #state { depth_delta = N } +set_synchronised(DeltaChange, State = #state { depth_delta = Delta }) -> + %% We intentionally leave out the head where a slave becomes + %% unsynchronised: we assert that can never happen. + case {Delta, Delta + DeltaChange} of + {0, 0} -> State; + {_, 0} -> ok = record_synchronised(State#state.q), + State #state { depth_delta = 0 }; + {_, N} when N > 0 -> State #state { depth_delta = N } end. record_synchronised(#amqqueue { name = QName }) -> |