[erlang-questions] gen_server call and reply

Ulf Wiger ulf@REDACTED
Sun Sep 16 21:19:53 CEST 2007

Well, I see nothing in the docs stating that gen_server:reply/2
is expected to be called after having returned {noreply, S}.
There is no rule stating that the server must reply to requests
at all, so the gen_server module is wise not to buffer any information
about requests that have triggered a {noreply, _} response.
Since it cannot buffer info, it cannot really use anything in the
reply that the callback doesn't already know, i.e. the Client
info passed to the handle_call/3 function.

But to be on the safe side, we could always ask the documentation
team at OTP to state clearly that it is perfectly fine to call
gen_server:reply/2 before returning {noreply, S}.


2007/9/16, Matthias Lang <matthias@REDACTED>:
> Ulf "Gung Ho" Wiger writes:
>  > Ah, well, you _can_ do it. Don't pay too much attention to the
>  > word "after". It's no problem whatsoever calling reply() first,
>  > and then returning {noreply, S}.
> I can see that it's no problem in the gen_server implementation.
> But I can't see anything in the documentation which prohibits a future
> gen_server from breaking the reply-before-return.
> So the paranoid and prudent might prefer to avoid calling reply()
> first, unless you know that a large Ericsson project contains code
> like that, in which case you can relax. ;-)
> Matthias

More information about the erlang-questions mailing list