Skip to content

Commit

Permalink
Remove exclusivity from safe_loop (only fix from combined_version)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vagabond committed Jul 24, 2010
1 parent 3e3aaa0 commit 64903e4
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/gen_leader.erl
Expand Up @@ -460,24 +460,22 @@ safe_loop(#server{mod = Mod, state = State} = Server, Role,
#election{name = Name} = E, _PrevMsg) ->
%% Event for QuickCheck
%% ?EVENT({Role,E}),
receive
Msg ->
case Msg of
{system, From, Req} ->
#server{parent = Parent, debug = Debug} = Server,
sys:handle_system_msg(Req, From, Parent, ?MODULE, Debug,
[safe, Server, Role, E]);
{'EXIT', _, Reason} = Msg ->
terminate(Reason, Msg, Server, Role, E);
{halt,T,From} = Msg ->
NewE = halting(E,T,From,Server),
From ! {ackLeader,T,self()},
safe_loop(Server,Role,NewE,Msg);
{hasLeader,Ldr,T,_} = Msg ->
NewE1 = mon_node(E,Ldr,Server),
case ( (E#election.status == elec2) and (E#election.acks /= []) ) of
true ->
lists:foreach(
receive
{system, From, Req} ->
#server{parent = Parent, debug = Debug} = Server,
sys:handle_system_msg(Req, From, Parent, ?MODULE, Debug,
[safe, Server, Role, E]);
{'EXIT', _, Reason} = Msg ->
terminate(Reason, Msg, Server, Role, E);
{halt,T,From} = Msg ->
NewE = halting(E,T,From,Server),
From ! {ackLeader,T,self()},
safe_loop(Server,Role,NewE,Msg);
{hasLeader,Ldr,T,_} = Msg ->
NewE1 = mon_node(E,Ldr,Server),
case ( (E#election.status == elec2) and (E#election.acks /= []) ) of
true ->
lists:foreach(
fun(Node) ->
{Name,Node} ! {hasLeader,Ldr,T,self()}
end,E#election.acks);
Expand Down Expand Up @@ -665,7 +663,6 @@ safe_loop(#server{mod = Mod, state = State} = Server, Role,
end
end,
hasBecomeLeader(NewE,Server,Msg)
end
end.


Expand Down

0 comments on commit 64903e4

Please sign in to comment.