[erlang-questions] Is gen_server handle_info synchronous?

Jeroen Koops koops.j@REDACTED
Wed Mar 3 21:57:01 CET 2010


Hi Chris,

As far as I can tell, you're doing it right - handle_info is invoked
synchronously (as are all gen_server's callbacks) and data saved in the
state on one invocation to handle_info is available on a subsequent
invocation. So the problem must be elsewhere - if you can share some of your
source-code, maybe we can help.



On Wed, Mar 3, 2010 at 9:37 PM, Chris Duesing <chris.duesing@REDACTED>wrote:

> I am working on some code that connects to a streaming data service
> via gen_tcp:connect(). I am doing this from inside a gen_server to
> benefit from OTP goodness. But, since it didn't seem to fit the
> paradigm to have an infinite loop of reading from the socket with
> recv, I left it as {active, once} and use handle_info to receive
> blocks of data. Whenever I receive an incomplete message in
> handle_info I just add it to the state, and then prepend it to the
> data I receive the next time handle_info is called. Once I started
> testing this code I am seeing that the data saved in the state is not
> available the next time handle_info is called. I guess I assumed that
> the gen_server would complete requests serially, is this not the case
> or am I missing something?
>
> Thanks,
>
> Chris
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>


More information about the erlang-questions mailing list