summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Videla <videlalvaro@gmail.com>2015-10-01 23:57:53 +0200
committerAlvaro Videla <videlalvaro@gmail.com>2015-10-01 23:57:53 +0200
commit701ee991cee61160d569277213a94c0d5b90c283 (patch)
tree76be702f2c1dcf21155c44b9babd22c2e17875a1 /src
parentef2d3f3976d7a504326b2af46490625dcb25c3ce (diff)
downloadrabbitmq-server-git-701ee991cee61160d569277213a94c0d5b90c283.tar.gz
refactors msg broadcast
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_mirror_queue_sync.erl16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/rabbit_mirror_queue_sync.erl b/src/rabbit_mirror_queue_sync.erl
index 3ef4e9d9ac..3e55a39178 100644
--- a/src/rabbit_mirror_queue_sync.erl
+++ b/src/rabbit_mirror_queue_sync.erl
@@ -245,17 +245,11 @@ syncer_loop(Ref, MPid, SPids) ->
receive
{msg, Ref, Msg, MsgProps, Unacked} ->
SPids1 = wait_for_credit(SPids),
- [begin
- credit_flow:send(SPid),
- SPid ! {sync_msg, Ref, Msg, MsgProps, Unacked}
- end || SPid <- SPids1],
+ broadcast(SPids1, {sync_msg, Ref, Msg, MsgProps, Unacked}),
syncer_loop(Ref, MPid, SPids1);
{msgs, Ref, Msgs} ->
SPids1 = wait_for_credit(SPids),
- [begin
- credit_flow:send(SPid),
- SPid ! {sync_msgs, Ref, Msgs}
- end || SPid <- SPids1],
+ broadcast(SPids1, {sync_msgs, Ref, Msgs}),
syncer_loop(Ref, MPid, SPids1);
{cancel, Ref} ->
%% We don't tell the slaves we will die - so when we do
@@ -266,6 +260,12 @@ syncer_loop(Ref, MPid, SPids) ->
[SPid ! {sync_complete, Ref} || SPid <- SPids]
end.
+broadcast(SPids, Msg) ->
+ [begin
+ credit_flow:send(SPid),
+ SPid ! Msg
+ end || SPid <- SPids],
+
wait_for_credit(SPids) ->
case credit_flow:blocked() of
true -> receive