[erlang-questions] Match Made In Heaven: proc_lib:spawnlink(Node, M, F, A) & gen_server:call({global, ?SERVER}, a marriage?

db masterofquestions@REDACTED
Tue Apr 22 01:27:07 CEST 2008


I have a global gen_server on nodeA and the clients are spawned on
remote nodes(B,C,...) from nodeA by a another gen_server. Common
supervisor that supervise both gen_server for client and global
gen_server on NodeA.

nodeA
    |-supervisor
          |-global_gen_server
          |-client_gen_server (this gen_server uses
proc_lib:spawn_link(Node, M, F, A) to spawn clients on remote nodes
and respawn client onto remote nodes if they die).

If the supervisor on nodeA sends terminate signal to global_gen_server
and client_gen_server, I need the remote clients to also die.

I use proc_lib to spawn the client on remote node.
Proc_lib:spawn_link(Node, M, F, A) has looping structure as follows:

loop(...) ->
    receive
        ...

        {'EXIT', Parent, Reason} ->
            ..maybe some cleaning up here..
            exit(Reason);
        ...
    end.

How can I call gen_server:call({global, ?SERVER} inside this loop, so
that the reply from the gen_server hits one of the receive condition.
Is proc_lib:spawn_link and gen_server:call({global, ?SERVER} a match
made in heaven or I have to go with proc_lib:spawn_link and
gen_server:cast({global, ?SERVER}?

Thank you.
-- 
rk

That which we persist in doing becomes easier for us to do; not that
the nature of the thing itself is changed, but that our power to do is
increased.
-Ralph Waldo Emerson



More information about the erlang-questions mailing list