[erlang-bugs] gen_server documentation error
Erik Søe Sørensen
ess@REDACTED
Tue Jun 28 09:53:23 CEST 2011
I think it would appeal more to intuition if the code is fixed rather
than the documentation... i.e. swap the two actions.
That would keep all replies before the terminate action.
Adam Lindberg wrote:
> 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