[erlang-questions] Trying to use gen_leader and gdict
Ulf Wiger (TN/EAB)
ulf.wiger@REDACTED
Tue Oct 2 09:40:21 CEST 2007
Jack Orenstein wrote:
> I am running Erlang R11B on OS X and have been investigating
> gen_leader. I'm having some trouble with the gdict example included
> with gen_leader. I wrote the following program to use gdict:
> ...
>
> This causes a timeout:
>
> zack$ time erl -sname z -noshell -s test main -s init stop
> init({dict,0,
> 16,
> 16,
> 8,
> 80,
> 48,
> {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
> {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}})
> {"init terminating in do_boot",{timeout,{gen_leader,leader_call,
> [<0.34.0>,{store,#Fun<gdict.0.10659195>}]}}}
> ...
>
> Can anyone see what I'm doing wrong?
You're not doing anything wrong. There's a bug in gen_leader.
When you start gen_leader with only one candidate node, it
will still go into a receive loop waiting for responses from
other candidates.
I have a patched version of gen_leader:
svn co http://svn.ulf.wiger.net/gproc/patches/gen_leader
It has a few other unverified* patches, such as the ability
to start gen_leader with no nodes at all (local-only mode) and
then triggering leader election by the callback returning
{activate, Cands, ...}.
* Note that gen_leader is very well tested (except, obviously,
for the case where you start gen_leader with only one candidate).
So "unverified" here means that I've only put this code through
very limited testing.
BR,
Ulf W
More information about the erlang-questions
mailing list