summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2012-08-31 19:05:58 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2012-08-31 19:05:58 +0100
commit188a756593a26db18345f6a95145f9bc9e35164e (patch)
treea41e5f3445f490dc2b4c5ddbef8cca637238da3e
parent5cb13a8445ac522bf201118bbbfe9054be7be4fb (diff)
downloadrabbitmq-server-188a756593a26db18345f6a95145f9bc9e35164e.tar.gz
refactoring: inline helper function
-rw-r--r--src/rabbit_mirror_queue_slave.erl49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl
index 54546f75..6882b2da 100644
--- a/src/rabbit_mirror_queue_slave.erl
+++ b/src/rabbit_mirror_queue_slave.erl
@@ -920,29 +920,30 @@ set_synchronised(_, _, State = #state { unknown_pending = undefined }) ->
set_synchronised(PendingDelta, Length,
State = #state { backing_queue = BQ,
backing_queue_state = BQS,
- unknown_pending = ExtPending }) ->
+ unknown_pending = ExtPending,
+ synchronised = Sync}) ->
ExtPending1 = ExtPending + PendingDelta,
true = ExtPending1 >= 0,
- set_synchronised1(ExtPending1 =:= 0 andalso Length =:= BQ:len(BQS),
- State #state { unknown_pending = ExtPending1 }).
-
-%% We intentionally leave out the head where a slave becomes
-%% unsynchronised: we assert that can never happen.
-set_synchronised1(true, State = #state { q = #amqqueue { name = QName },
- synchronised = false }) ->
- Self = self(),
- rabbit_misc:execute_mnesia_transaction(
- fun () ->
- case mnesia:read({rabbit_queue, QName}) of
- [] ->
- ok;
- [Q1 = #amqqueue{sync_slave_pids = SSPids}] ->
- Q2 = Q1#amqqueue{sync_slave_pids = [Self | SSPids]},
- rabbit_mirror_queue_misc:store_updated_slaves(Q2)
- end
- end),
- State #state { synchronised = true };
-set_synchronised1(true, State) ->
- State;
-set_synchronised1(false, State = #state { synchronised = false }) ->
- State.
+ State1 = State #state { unknown_pending = ExtPending1 },
+ %% We intentionally leave out the head where a slave becomes
+ %% unsynchronised: we assert that can never happen.
+ case {Sync, ExtPending1 =:= 0 andalso Length =:= BQ:len(BQS)} of
+ {true, true} ->
+ State1;
+ {false, false} ->
+ State1;
+ {false, true} ->
+ Self = self(),
+ #state{ q = #amqqueue { name = QName } } = State1,
+ rabbit_misc:execute_mnesia_transaction(
+ fun () ->
+ case mnesia:read({rabbit_queue, QName}) of
+ [] ->
+ ok;
+ [Q1 = #amqqueue{sync_slave_pids = SSPids}] ->
+ rabbit_mirror_queue_misc:store_updated_slaves(
+ Q1#amqqueue{sync_slave_pids = [Self | SSPids]})
+ end
+ end),
+ State1 #state { synchronised = true }
+ end.