Hi!

I have a quick question:
in *boss_web_controller:call_controller_action, *there is new process 
spawned,
just to do job and and send result back to parent.

call_controller_action(Adapter, AdapterInfo, RequestContext) ->
    lager:notice("Calling Controller Adapter ~s", [Adapter]),
    process_flag(trap_exit, true),
    Ref                = make_ref(),
    CHandlerPid = self(),
    _N = spawn_link(fun() ->
                            R = Adapter:action(AdapterInfo, RequestContext),
                            CHandlerPid !{msg,Ref, R}
               end),
    receive_controller_response(Ref).

-spec(receive_controller_response(reference()) ->any()).
receive_controller_response(Ref) ->
    receive
        {msg, Ref, R} ->
            lager:notice("Response ~p", [R]),
            R;

        {'EXIT',_From, normal} ->        
            %%lager:error("2 Controller Process Exited normal ~p but response 
not yet receive", [From]),
            receive_controller_response(Ref);

        {'EXIT',From, Reason} ->        
            lager:error("Controller Process Exited ~p ~p", [From, Reason]),
            {output, "Process Error see console.log for details\n"}
    end.

Is there some reason for that?
It is synchronous, so it could be replaced with:

call_controller_action(Adapter, AdapterInfo, RequestContext) ->
    Adapter:action(AdapterInfo, RequestContext).

Or maybe surround the call in try ... catch.
If there is no reason for spawning new process, than I'll make a pull request,
if there is - I would really like to know :)

-- 
You received this message because you are subscribed to the Google Groups 
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/chicagoboss/54309ef5-d54a-4a4d-accf-1cbf7a88275c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to