Linking to/from a gen_server?

Shawn Pearce <>
Sun Mar 2 07:25:55 CET 2003


Ok, so I'm trying to use OTP stuff as much as I can right now, as I
haven't really learned it all yet.  :)

I'm trying to setup a way to have a client process send a gen_server
a message, where the gen_server stuffs a term and the client's pid
into an ets table managed by the gen_server.  I want the gen_server
to link to the client process so it can remove the term and client
pid when the client process exits.

But it occured to me, gen_server:call/2 links to the gen_server
process, sends the message, and waits for the response with a
timeout.  It then unlinks from the gen_server.  This means the
gen_server can't link to the client process during its handle_call/3
callback, as the unlink will be done by the client after the call
completes.

I could use gen_server:cast/2, but i do need a response to be sent
back to the client so it knows the operation was successful.

Ideas from the OTP experts?

-- 
Shawn.

  You shall be rewarded for a dastardly deed.



More information about the erlang-questions mailing list