[erlang-bugs] gen_server documentation error

Adam Lindberg adam@REDACTED
Tue Jun 28 09:32:24 CEST 2011


Hi,

In the documentation for Module:handle_call/3 in the gen_server module, 
it states:

> If the function returns {stop,Reason,Reply,NewState}, Reply will be given back to From. If the function returns {stop,Reason,NewState}, any reply to From must be given explicitly using gen_server:reply/2. The gen_server will then call Module:terminate(Reason,NewState) and terminate.

This is false.

The true behavior exists on line 573:

     {stop, Reason, Reply, NState} ->
         {'EXIT', R} =
             (catch terminate(Reason, Name, Msg, Mod, NState, [])),
         reply(From, Reply),
         exit(R);

The documentation should probably read:

If the function returns {stop,Reason,Reply,NewState}, the gen_server 
will call Module:terminate(Reason,NewState) and Reply will be given back 
to From after the call to Module:terminate/2 has completed. If the 
function returns {stop,Reason,NewState}, any reply to From must be given 
explicitly using gen_server:reply/2.

Cheers,
Adam




More information about the erlang-bugs mailing list