[erlang-questions] race condition when stopping/starting a gen_server - bug?

Lukas P <>
Thu Nov 3 11:35:26 CET 2011


Hello,

in my eunit tests I am starting/stopping a gen_server.

The code used to fail occassionally - gen_server's process name was still
registered when gen_server:call(?SERVER, stop) returned and the next
gen_server:start_link({local, ?SERVER}...) failed with
{error,{already_started,_}}.

Adding unregister to gen_server's terminate/2 solved the problem
(terminate/2 is called before responding to the stop request), but is there
a reason why gen_server does not unregister its name at the right time?

Thanks, Lukas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111103/35fa8de7/attachment.html>


More information about the erlang-questions mailing list