[erlang-questions] simple_one_by_one trouble and rare start_link/2 gen_fsm

Angel J. Alvarez Miguel clist@REDACTED
Thu Jun 21 09:30:15 CEST 2012


That's right...

But start_link it is expected to be or arity 3 and Opts is a property list.

but then on test:main/0 when i do supervisor:start_child(SupPid,Opts2) 

being Opts2 another property list, then suppervisor should call: 

apply(sim_group_fsm,start_link,Opts ++ Opts2) on its line 319 which in turn calls gen_fsm:start_link, thus providing a Pid in the end...  

but what it really does is apply(sim_group_fsm,start_link,Opts ++ Opts2,[ ]) and then crashes unless i declare a start_link/2 on my gen_fsm...

{
	{badmatch,
		{error,
			{'EXIT',
				{undef,
					[
					{sim_group_fsm,start_link,[[{option1,40}],[{option29,100}]],[]},
					{supervisor,do_start_child_i,3,[
												{file,"supervisor.erl"},
												{line,319}
												]}......

i dont see why i finish having a apply/4 call in supervisor: 319 instead of an apply/3...

I want the sup to propagate one property list to children specs while i will provide another during children spawns
providing that sup combines two in any way children will manage to demunge ...both property lists

So cant just see what im doing wrong....

/angel


PS: i changed a bit the test code to force sup crash

On Jueves, 21 de Junio de 2012 06:22:54 Vance Shipley escribió:
> On Thu, Jun 21, 2012 at 12:30:08AM +0200, Angel J. Alvarez Miguel wrote:
> }  While calling a simple_one_by_one supervisor to start a gen fsm I found
> }  it causes calling a start_link/2 function on the callback module of the
> }  gen_fsm.
> 
> You are specifying that function to be called to start the worker yourself.
> In your module group_supervisor.erl you provide a child_spec() in the
> return value of init/1:
> 
>   {mucfsm, {sim_group_fsm, start_link, [Opts]}, transient, 60, worker,
> [sim_group]}
> 
> 
> The form of which is:
> 
>    {Id, StartFunc, Restart, Shutdown, Type, Modules}
> 
> The second argument, StartFunc, has the form:
> 
>    {Module, Function, Arguments}
> 
> You provided:
> 
> 	{sim_group_fsm, start_link, [Opts]}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: group_supervisor.erl
Type: text/x-erlang
Size: 528 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120621/b575bcb8/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sim_group_fsm.erl
Type: text/x-erlang
Size: 2329 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120621/b575bcb8/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.erl
Type: text/x-erlang
Size: 576 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120621/b575bcb8/attachment-0002.bin>


More information about the erlang-questions mailing list