Concurrency problem

Klacke klacke@REDACTED
Thu Aug 5 10:28:15 CEST 1999



> I'm wondering if someone can help me with a pattern for avoiding a
> deadlock.  Fundamentally, my problem is this:
> 
> I have two gen_server processes, A and B.  A wants to make a call on
> B for the sake of the side-effects.  These side-effects involve making 
> calls to A.
> 

This is a classic situation, I've encoutered the
same problem over and over again. Mnesia is for example
full with code that really would like to make a simple 
gen_server:call to the remote side but can't do it since the
other side would then do the same.

You need to do some sort of async solution here.

1. Send request.  (gen_server:cast)
2. Mark request as outstanding, (change server state)
3. When reply comes handle it as usual.

A bit irritating since this is such a common situation.

Cheers

/klacke




More information about the erlang-questions mailing list