summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2013-01-01 12:44:45 +0000
committerMatthias Radestock <matthias@rabbitmq.com>2013-01-01 12:44:45 +0000
commit4aa86fc039e0fdd7adf41b3b4e50b821c753a129 (patch)
treeb79c070255a955bbc4ef68e50711f18480a5c97d
parentbd366efb9320c18f17ff2bfb229533c68233454a (diff)
downloadrabbitmq-server-4aa86fc039e0fdd7adf41b3b4e50b821c753a129.tar.gz
refactor: extract stop_syncer function
-rw-r--r--src/rabbit_mirror_queue_sync.erl19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/rabbit_mirror_queue_sync.erl b/src/rabbit_mirror_queue_sync.erl
index e3edecb5..38a18e4a 100644
--- a/src/rabbit_mirror_queue_sync.erl
+++ b/src/rabbit_mirror_queue_sync.erl
@@ -94,11 +94,7 @@ master_send(Msg, MsgProps, {Syncer, Ref, Log, HandleInfo, EmitStats, Parent},
end,
receive
{'$gen_call', From,
- cancel_sync_mirrors} -> unlink(Syncer),
- Syncer ! {cancel, Ref},
- receive {'EXIT', Syncer, _} -> ok
- after 0 -> ok
- end,
+ cancel_sync_mirrors} -> stop_syncer(Syncer, {cancel, Ref}),
gen_server2:reply(From, ok),
{stop, cancelled};
{next, Ref} -> Syncer ! {msg, Ref, Msg, MsgProps},
@@ -109,16 +105,19 @@ master_send(Msg, MsgProps, {Syncer, Ref, Log, HandleInfo, EmitStats, Parent},
master_done({Syncer, Ref, _Log, _HandleInfo, _EmitStats, Parent}, BQS) ->
receive
- {next, Ref} -> unlink(Syncer),
- Syncer ! {done, Ref},
- receive {'EXIT', Syncer, _} -> ok
- after 0 -> ok
- end,
+ {next, Ref} -> stop_syncer(Syncer, {done, Ref}),
{ok, BQS};
{'EXIT', Parent, Reason} -> {shutdown, Reason, BQS};
{'EXIT', Syncer, Reason} -> {sync_died, Reason, BQS}
end.
+stop_syncer(Syncer, Msg) ->
+ unlink(Syncer),
+ Syncer ! Msg,
+ receive {'EXIT', Syncer, _} -> ok
+ after 0 -> ok
+ end.
+
%% Master
%% ---------------------------------------------------------------------------
%% Syncer