diff options
author | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-08-30 17:38:34 +0100 |
---|---|---|
committer | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-08-30 17:38:34 +0100 |
commit | ec9c54a99566adbc905152a19e2179902fd52a1d (patch) | |
tree | 62938b905a51eee6158ac3138b822a89e58e88f7 | |
parent | d22b4dd1b543bc969a370178bd0d2e44c616ff51 (diff) | |
download | rabbitmq-server-ec9c54a99566adbc905152a19e2179902fd52a1d.tar.gz |
matthias doesn't like the nested `set_synchronised' :(
-rw-r--r-- | src/rabbit_mirror_queue_slave.erl | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl index 2c60acf0..58b9b644 100644 --- a/src/rabbit_mirror_queue_slave.erl +++ b/src/rabbit_mirror_queue_slave.erl @@ -817,26 +817,24 @@ process_instruction({set_length, Length, Dropped, AckRequired}, QLen = BQ:len(BQS), ToDrop = QLen - Length, {ok, - set_synchronised( - Length, - case ToDrop >= 0 of - true -> - State1 = - lists:foldl( - fun (const, StateN = #state{backing_queue_state = BQSN}) -> - {{#basic_message{id = MsgId}, _, AckTag, _}, - BQSN1} = BQ:fetch(AckRequired, BQSN), - maybe_store_ack( - AckRequired, MsgId, AckTag, - StateN #state { backing_queue_state = BQSN1 }) - end, State, lists:duplicate(ToDrop, const)), - case AckRequired of - true -> set_synchronised(ToDrop, Dropped, Length, State1); - false -> State1 - end; - false -> - State - end)}; + case ToDrop >= 0 of + true -> + State1 = + lists:foldl( + fun (const, StateN = #state{backing_queue_state = BQSN}) -> + {{#basic_message{id = MsgId}, _, AckTag, _}, BQSN1} = + BQ:fetch(AckRequired, BQSN), + maybe_store_ack( + AckRequired, MsgId, AckTag, + StateN #state { backing_queue_state = BQSN1 }) + end, State, lists:duplicate(ToDrop, const)), + case AckRequired of + true -> set_synchronised(ToDrop, Dropped, Length, State1); + false -> set_synchronised(Length, State1) + end; + false -> + set_synchronised(Length, State) + end}; process_instruction({fetch, AckRequired, MsgId, Remaining}, State = #state { backing_queue = BQ, backing_queue_state = BQS, |