summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-09-17 15:03:24 +0100
committerSimon MacMullen <simon@rabbitmq.com>2014-09-17 15:03:24 +0100
commit5514a3c3055619fa0391bbc4d3cb4fc0f2250763 (patch)
treee77ae182a3f4ad4b0abeb291b6a00efc4eb07167
parent4bf5e38631ee0ea97b2ecb1ec3c874daf1fe6b57 (diff)
downloadrabbitmq-server-5514a3c3055619fa0391bbc4d3cb4fc0f2250763.tar.gz
Rename GM:terminate/2 to GM:handle_terminate/2 so that it doesn't conflict with the same callback in gen_server.
-rw-r--r--include/gm_specs.hrl8
-rw-r--r--src/gm.erl8
-rw-r--r--src/gm_soak_test.erl4
-rw-r--r--src/gm_speed_test.erl4
-rw-r--r--src/gm_tests.erl4
-rw-r--r--src/rabbit_mirror_queue_coordinator.erl9
-rw-r--r--src/rabbit_mirror_queue_slave.erl10
7 files changed, 23 insertions, 24 deletions
diff --git a/include/gm_specs.hrl b/include/gm_specs.hrl
index 245c23bc..d8686cd1 100644
--- a/include/gm_specs.hrl
+++ b/include/gm_specs.hrl
@@ -20,9 +20,9 @@
-type(args() :: any()).
-type(members() :: [pid()]).
--spec(joined/2 :: (args(), members()) -> callback_result()).
--spec(members_changed/3 :: (args(), members(), members()) -> callback_result()).
--spec(handle_msg/3 :: (args(), pid(), any()) -> callback_result()).
--spec(terminate/2 :: (args(), term()) -> any()).
+-spec(joined/2 :: (args(), members()) -> callback_result()).
+-spec(members_changed/3 :: (args(), members(),members()) -> callback_result()).
+-spec(handle_msg/3 :: (args(), pid(), any()) -> callback_result()).
+-spec(handle_terminate/2 :: (args(), term()) -> any()).
-endif.
diff --git a/src/gm.erl b/src/gm.erl
index 3113f449..6c09e664 100644
--- a/src/gm.erl
+++ b/src/gm.erl
@@ -62,7 +62,7 @@
%%
%% leave/1
%% Provide the Pid. Removes the Pid from the group. The callback
-%% terminate/2 function will be called.
+%% handle_terminate/2 function will be called.
%%
%% broadcast/2
%% Provide the Pid and a Message. The message will be sent to all
@@ -493,13 +493,13 @@
%% Called on gm member termination as per rules in gen_server, with
%% the Args provided in start_link plus the termination Reason.
--callback terminate(Args :: term(), Reason :: term()) ->
+-callback handle_terminate(Args :: term(), Reason :: term()) ->
ok | term().
-else.
behaviour_info(callbacks) ->
- [{joined, 2}, {members_changed, 3}, {handle_msg, 3}, {terminate, 2}];
+ [{joined, 2}, {members_changed, 3}, {handle_msg, 3}, {handle_terminate, 2}];
behaviour_info(_Other) ->
undefined.
@@ -737,7 +737,7 @@ handle_info({'DOWN', MRef, process, _Pid, Reason},
terminate(Reason, State = #state { module = Module,
callback_args = Args }) ->
flush_broadcast_buffer(State),
- Module:terminate(Args, Reason).
+ Module:handle_terminate(Args, Reason).
code_change(_OldVsn, State, _Extra) ->
diff --git a/src/gm_soak_test.erl b/src/gm_soak_test.erl
index c9a25522..90b94e42 100644
--- a/src/gm_soak_test.erl
+++ b/src/gm_soak_test.erl
@@ -17,7 +17,7 @@
-module(gm_soak_test).
-export([test/0]).
--export([joined/2, members_changed/3, handle_msg/3, terminate/2]).
+-export([joined/2, members_changed/3, handle_msg/3, handle_terminate/2]).
-behaviour(gm).
@@ -94,7 +94,7 @@ handle_msg([], From, {test_msg, Num}) ->
end),
ok.
-terminate([], Reason) ->
+handle_terminate([], Reason) ->
io:format("Left ~p (~p)~n", [self(), Reason]),
ok.
diff --git a/src/gm_speed_test.erl b/src/gm_speed_test.erl
index 41be6dd8..f2aedff6 100644
--- a/src/gm_speed_test.erl
+++ b/src/gm_speed_test.erl
@@ -17,7 +17,7 @@
-module(gm_speed_test).
-export([test/3]).
--export([joined/2, members_changed/3, handle_msg/3, terminate/2]).
+-export([joined/2, members_changed/3, handle_msg/3, handle_terminate/2]).
-export([wile_e_coyote/2]).
-behaviour(gm).
@@ -37,7 +37,7 @@ handle_msg(Owner, _From, ping) ->
Owner ! ping,
ok.
-terminate(Owner, _Reason) ->
+handle_terminate(Owner, _Reason) ->
Owner ! terminated,
ok.
diff --git a/src/gm_tests.erl b/src/gm_tests.erl
index cae2164b..db552ce7 100644
--- a/src/gm_tests.erl
+++ b/src/gm_tests.erl
@@ -22,7 +22,7 @@
test_member_death/0,
test_receive_in_order/0,
all_tests/0]).
--export([joined/2, members_changed/3, handle_msg/3, terminate/2]).
+-export([joined/2, members_changed/3, handle_msg/3, handle_terminate/2]).
-behaviour(gm).
@@ -48,7 +48,7 @@ handle_msg(Pid, From, Msg) ->
Pid ! {msg, self(), From, Msg},
ok.
-terminate(Pid, Reason) ->
+handle_terminate(Pid, Reason) ->
Pid ! {termination, self(), Reason},
ok.
diff --git a/src/rabbit_mirror_queue_coordinator.erl b/src/rabbit_mirror_queue_coordinator.erl
index 23718da1..3d460528 100644
--- a/src/rabbit_mirror_queue_coordinator.erl
+++ b/src/rabbit_mirror_queue_coordinator.erl
@@ -21,7 +21,7 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
code_change/3]).
--export([joined/2, members_changed/3, handle_msg/3]).
+-export([joined/2, members_changed/3, handle_msg/3, handle_terminate/2]).
-behaviour(gen_server2).
-behaviour(gm).
@@ -384,10 +384,6 @@ handle_info(Msg, State) ->
{stop, {unexpected_info, Msg}, State}.
terminate(_Reason, #state{}) ->
- %% gen_server case
- ok;
-terminate([_CPid], _Reason) ->
- %% gm case
ok.
code_change(_OldVsn, State, _Extra) ->
@@ -416,6 +412,9 @@ handle_msg([CPid], _From, {delete_and_terminate, _Reason} = Msg) ->
handle_msg([_CPid], _From, _Msg) ->
ok.
+handle_terminate([_CPid], _Reason) ->
+ ok.
+
%% ---------------------------------------------------------------------------
%% Others
%% ---------------------------------------------------------------------------
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl
index 2da2e7a5..af1e2141 100644
--- a/src/rabbit_mirror_queue_slave.erl
+++ b/src/rabbit_mirror_queue_slave.erl
@@ -30,7 +30,7 @@
code_change/3, handle_pre_hibernate/1, prioritise_call/4,
prioritise_cast/3, prioritise_info/3, format_message_queue/2]).
--export([joined/2, members_changed/3, handle_msg/3]).
+-export([joined/2, members_changed/3, handle_msg/3, handle_terminate/2]).
-behaviour(gen_server2).
-behaviour(gm).
@@ -338,10 +338,7 @@ terminate({shutdown, _} = R, State) ->
terminate(Reason, State = #state{backing_queue = BQ,
backing_queue_state = BQS}) ->
terminate_common(State),
- BQ:delete_and_terminate(Reason, BQS);
-terminate([_SPid], _Reason) ->
- %% gm case
- ok.
+ BQ:delete_and_terminate(Reason, BQS).
%% If the Reason is shutdown, or {shutdown, _}, it is not the queue
%% being deleted: it's just the node going down. Even though we're a
@@ -438,6 +435,9 @@ handle_msg([SPid], _From, {sync_start, Ref, Syncer, SPids}) ->
handle_msg([SPid], _From, Msg) ->
ok = gen_server2:cast(SPid, {gm, Msg}).
+handle_terminate([_SPid], _Reason) ->
+ ok.
+
%% ---------------------------------------------------------------------------
%% Others
%% ---------------------------------------------------------------------------