summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmile Joubert <emile@rabbitmq.com>2012-05-23 16:30:49 +0100
committerEmile Joubert <emile@rabbitmq.com>2012-05-23 16:30:49 +0100
commitf8f1c10ff33d09fe824c3adb603419fdf1698047 (patch)
tree2be6db4f8e17115b82794aab4eeae83f03b21503
parent84d79f62d8e96f14f6aca14fdace831b568bff50 (diff)
downloadrabbitmq-server-bug24954.tar.gz
Handle callback replies to handle_msg correctlybug24954
-rw-r--r--src/gm.erl34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/gm.erl b/src/gm.erl
index 01300f18..1f11a89c 100644
--- a/src/gm.erl
+++ b/src/gm.erl
@@ -1287,16 +1287,30 @@ send_right(Right, View, Msg) ->
ok = gen_server2:cast(get_pid(Right), {?TAG, view_version(View), Msg}).
callback(Args, Module, Activity) ->
- lists:foldl(
- fun ({Id, Pubs, _Acks}, ok) ->
- lists:foldl(fun ({_PubNum, Pub}, ok) ->
- Module:handle_msg(Args, get_pid(Id), Pub);
- (_, Error) ->
- Error
- end, ok, Pubs);
- (_, Error) ->
- Error
- end, ok, Activity).
+ Result =
+ lists:foldl(
+ fun ({Id, Pubs, _Acks}, {Args1, Module1, ok}) ->
+ lists:foldl(fun ({_PubNum, Pub}, Acc = {Args2, Module2, ok}) ->
+ case Module2:handle_msg(
+ Args2, get_pid(Id), Pub) of
+ ok ->
+ Acc;
+ {become, Module3, Args3} ->
+ {Args3, Module3, ok};
+ {stop, _Reason} = Error ->
+ Error
+ end;
+ (_, Error = {stop, _Reason}) ->
+ Error
+ end, {Args1, Module1, ok}, Pubs);
+ (_, Error = {stop, _Reason}) ->
+ Error
+ end, {Args, Module, ok}, Activity),
+ case Result of
+ {Args, Module, ok} -> ok;
+ {Args1, Module1, ok} -> {become, Module1, Args1};
+ {stop, _Reason} = Error -> Error
+ end.
callback_view_changed(Args, Module, OldView, NewView) ->
OldMembers = all_known_members(OldView),