<div dir="ltr">So no. I did not send it any event.<br>Serge, I enabled sasl via application:start/1 but when I ran the function in question I didn't get any output from it.<br><br><div class="gmail_quote">On Wed, Aug 20, 2008 at 1:00 PM, Mazen Harake <span dir="ltr"><<a href="mailto:mazen@erlang-consulting.com">mazen@erlang-consulting.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Matt,<br>
<br>
Sorry this might be a stupid question but did you send it an event?<br>
<br>
/Mazen<br>
<br>
Matt Williamson wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">
I hate to keep bugging with simple problems, but I'm stuck again. My FSM dosn't seem to be executing its first state. Here is my init function:<br>
<br>
/init(StartArgs) -><br>
InitialState = case StartArgs of<br>
{store_chunk, Chunk} -><br>
io:format("FSM Storing chunk...~n"),<br>
{ok, storing_chunk, [Chunk]};<br>
{get_chunk, Args} -><br>
{ok, getting_chunk, Args};<br>
Else -><br>
%% @todo Add error logging here.<br>
io:format("Bad arg for FSM: ~p~n", [StartArgs])<br>
end,<br>
io:format("FSM Initial State: ~p~n", [InitialState]),<br>
InitialState./<br>
<br>
storing_chunk/2 is exported and I'm not getting any errors. Here is that function:<br>
<br>
/storing_chunk(_Event, [Chunk]) -><br>
io:format("STATE: storing_chunk~n"),<br>
case erlfs_store_lib:store_chunk() of<br>
ok -><br>
{next_state, notifying_tracker, Chunk};<br>
{error, Reason} -><br>
%% @todo Add error logging here.<br>
io:format("FSM Stopped: ~p~n", [Reason]),<br>
{stop, {file, Reason}, Chunk#chunk.chunk_meta}<br>
end./<br>
<br></div></div><div class="Ih2E3d">
On Wed, Aug 20, 2008 at 11:04 AM, Serge Aleynikov <<a href="mailto:saleyn@gmail.com" target="_blank">saleyn@gmail.com</a> <mailto:<a href="mailto:saleyn@gmail.com" target="_blank">saleyn@gmail.com</a>>> wrote:<br>
<br>
The error you reported earlier:<br>
<br>
{'EXIT', {badarg, [{erlang, apply,<br>
[erlfs_store_worker_fsm, start_link, {store_chunk, ...}]}]}}<br>
<br>
was a clear indication that erlang:apply(M,F,A) was called with A<br>
being a tuple rather than a list. If this still doesn't work<br>
after replacing tuple with a list in the second argument of the<br>
supervisor:start_child/2 call, this means that you probably have<br>
other issues in the erlfs_store_worker_fsm:start_link/1 itself.<br>
<br>
I can't say anything more without seeing a more detailed error report.<br>
<br>
Serge<br>
<br>
<br>
Matt Williamson wrote:<br>
<br>
Yes, I saw that in the docs. What I was saying is that calling<br>
apply(M, F,<br>
A++List) =:= apply(M, F, List) when A =:= [].<br>
<br>
I did try your suggestion anyway with the same results.<br>
<br>
On Wed, Aug 20, 2008 at 9:54 AM, Serge Aleynikov<br></div><div class="Ih2E3d">
<<a href="mailto:saleyn@gmail.com" target="_blank">saleyn@gmail.com</a> <mailto:<a href="mailto:saleyn@gmail.com" target="_blank">saleyn@gmail.com</a>>> wrote:<br>
<br>
What is the arity of erlfs_store_worker_fsm:start_link<br>
function?<br>
<br>
Not quite sure what you mean by [] ++ 1 below.<br>
<br>
The supervisor:start_child/2 takes a list [term()] as the<br>
second parameter.<br>
Here's its docs:<br>
<br>
"If the case of a simple_one_for_one supervisor, the child<br>
specification<br>
defined in Module:init/1 will be used and ChildSpec should<br>
instead be an<br>
arbitrary list of terms List. The child process will then<br>
be started by<br>
appending List to the existing start function arguments,<br>
i.e. by calling<br>
apply(M, F, A++List) where {M,F,A} is the start function<br>
defined in the<br>
child specification."<br>
<br>
Note the A++List part.<br>
<br>
<br>
Matt Williamson wrote:<br>
<br>
I'm afraid that did not work. I am passing an empty<br>
list, and if I execute<br>
[] ++ 1 in the shell I get 1.<br>
<br>
On Wed, Aug 20, 2008 at 9:31 AM, Serge Aleynikov<br></div>
<<a href="mailto:saleyn@gmail.com" target="_blank">saleyn@gmail.com</a> <mailto:<a href="mailto:saleyn@gmail.com" target="_blank">saleyn@gmail.com</a>>><div><div></div><div class="Wj3C7c"><br>
wrote:<br>
<br>
Try starting it as:<br>
<br>
supervisor:start_child(erlfs_store_worker_sup,<br>
[{store_chunk, Chunk}])<br>
<br>
The simple_one_for_one strategy appends the<br>
arguments passed to<br>
supervisor:start_child/2 to the list of args<br>
specified in the<br>
supervisor's<br>
spec.<br>
<br>
Serge<br>
<br>
Matt Williamson wrote:<br>
<br>
Hello,<br>
<br>
I am starting a gen_fsm with<br>
supervisor:start_child(erlfs_store_worker_sup,<br>
{store_chunk, Chunk}) but I get the following<br>
error:<br>
<br>
{error,<br>
{'EXIT',<br>
{badarg,<br>
[{erlang,<br>
apply,<br>
[erlfs_store_worker_fsm,<br>
start_link,<br>
{store_chunk,<br>
{chunk,<br>
{chunk_meta,<br>
{file_meta,<br>
"test123",<br>
"test.txt",<br>
0,<br>
"text/plain",<br>
{{0,1,1},{0,0,0}}},<br>
0,<br>
0,<br>
[]},<br>
<<"Hello world!">>}}]},<br>
{supervisor,do_start_child_i,3},<br>
{supervisor,handle_call,3},<br>
{gen_server,handle_msg,6},<br>
{proc_lib,init_p,5}]}}}<br>
<br>
I've been trying to figure it out for a while,<br>
but I am having a hard<br>
time.<br>
Here is the Child Spec in the supervisor<br>
(erlfs_store_worker_sup):<br>
<br>
init(Args) -><br>
WorkerSpec = {erlfs_store_worker_fsm,<br>
{erlfs_store_worker_fsm,<br>
start_link, []},<br>
temporary, 2000, worker,<br>
[erlfs_store_worker_fsm]},<br>
{ok,{{simple_one_for_one, 0, 1}, [WorkerSpec]}}.<br>
<br>
<br>
<br>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br></div></div>
<mailto:<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a>><div class="Ih2E3d"><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
<br>
<br>
<br>
<br>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></blockquote>
<br>
<br>
-- <br>
Mazen Harake <<a href="mailto:mazen@erlang-consulting.com" target="_blank">mazen@erlang-consulting.com</a>><br>
Erlang Software Developer and Consultant,<br>
Erlang Training & Consulting, Ltd<br>
<br>
Mobile Phone: +44 (0)795 13 26 317<br>
Office Phone: +44 (0)207 45 61 020<br>
Office Address:<br>
401 London Fruit & Wool Exchange<br>
Brushfield St, London, E1 6EL<br>
United Kingdom<br>
<br>
This email and its attachments may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of "Erlang Training & Consulting, Ltd".<br>
<br>
If you are not the intended recipient of this email and its attachments, you must take no action based upon them, nor must you copy or show them to anyone. Please contact the sender if you believe you have received this email in error.<br>
<br>
</blockquote></div><br></div>