Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix worker activation #1

Merged
2 commits merged into from

2 participants

@sg2342

hi,
commit 7439255 allows to create a worker process
and commit a3ab9a4 activates the worker.

best regards.

@abecciu
Owner

Looks good, thanks!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 18, 2010
  1. @sg2342
  2. @sg2342

    fix worker activation

    sg2342 authored
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 15 deletions.
  1. +16 −15 src/gen_leader.erl
View
31 src/gen_leader.erl
@@ -467,10 +467,10 @@ init_it(Starter,Parent,Name,Mod,{CandidateNodes,OptArgs,Arg},Options) ->
false -> CandidateNodes
end,
case lists:member(node(), Workers) of
- false ->
+ true ->
rpc:multicall(Candidates, gen_leader,
worker_announce, [Name, node(self())]);
- true -> nop
+ false -> nop
end,
safe_loop(#server{parent = Parent,mod = Mod,
state = State,debug = Debug},
@@ -556,6 +556,20 @@ safe_loop(#server{mod = Mod, state = State} = Server, Role,
E
end,
hasBecomeLeader(NewE,Server,Msg);
+
+ {ldr,Synch,T,_,_,From} = Msg when Role == waiting_worker ->
+ case ( (T == E#election.elid)
+ and (node(From) == E#election.leadernode)) of
+ true ->
+ NewE = E#election{ leader = From, status = worker },
+ {ok,NewState} = Mod:surrendered(State,Synch,NewE),
+ loop(Server#server{state = NewState},worker,NewE,Msg);
+ false ->
+ %% This should be a VERY special case...
+ %% But doing nothing is the right thing!
+ %% A DOWN message should arrive to solve this situation
+ safe_loop(Server,Role,E,Msg)
+ end;
{ldr,Synch,T,Workers,Candidates,From} = Msg ->
case ( ( (E#election.status == wait) or (E#election.status == joining) )
and (E#election.elid == T) ) of
@@ -616,19 +630,6 @@ safe_loop(#server{mod = Mod, state = State} = Server, Role,
%% This process is no longer the leader!
%% The sender will notice this via a DOWN message
safe_loop(Server,Role,E,Msg);
- {activateWorker,T,Synch,From} = Msg ->
- case ( (T == E#election.elid)
- and (node(From) == E#election.leadernode)) of
- true ->
- NewE = E#election{ leader = From, status = worker },
- {ok,NewState} = Mod:surrendered(State,Synch,NewE),
- loop(Server#server{state = NewState},worker,NewE,Msg);
- false ->
- %% This should be a VERY special case...
- %% But doing nothing is the right thing!
- %% A DOWN message should arrive to solve this situation
- safe_loop(Server,Role,E,Msg)
- end;
{heartbeat, _Node} = Msg ->
safe_loop(Server,Role,E,Msg);
Something went wrong with that request. Please try again.