[erlang-questions] Forwarding call from one gen_server to another
Tue Jun 17 23:51:53 CEST 2008
Thanks for your reply. I was actually passing the From parameter back and
forth without knowing what it was exactly - I just assumed it was a naked
Pid. And I was worried that apparently, gen_server:call accepted a reply
from a process other than the process it sent the request to, opening up the
possibility for the client to interpret any message received as a response.
But now that you mention that From is actually a tuple containing a
reference making the call unique, it all makes sense.
-- Jeroen Koops
On Tue, Jun 17, 2008 at 8:33 PM, Paul Fisher <> wrote:
> On Tue, 2008-06-17 at 19:34 +0200, Jeroen Koops wrote:
> > I was wondering what the common way is to call one gen_server, have
> > this call forwarded to another gen_server, and have this other server
> > reply to the client. One way of doing this is by having the first
> > gen_server send a cast to the second gen_server, including the PID of
> > the client, and then respond with a noreply. The second gen_server
> > handles the cast by explicitly responding to the client using
> > gen_server:reply() - using the PID sent by the original gen_server, of
> > course. This seems to work, but it feels like a clumsy way to do it -
> > isn't there a better way?
> That's the way to do it (although you'll need to pass along the whole
> >From parameter, which is really a 2-arity tuple with the calling
> processes pid and a make_ref/0 specific to that call.)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions