Monitoring a recv_loop inside a gen_server
Bruce Fitzsimons
Bruce@REDACTED
Sat Jun 15 08:55:40 CEST 2002
People,
More questions...thanks to everyone who replied last time and I'm sorry if I
didn't reply to everyone.
I am using a udp recv_loop in conjunction with a gen_server, where the
gen_server:init starts the loop, and the loop processing makes calls to the
gen_server through its interface. I forget where I learnt this design
pattern, but it works well..
However, from time to time I create bugs which cause the recv_loop to crash.
The recv_loop has been started as an independent process (spawn), so when it
dies no one notices.
I believe the reason I did not use spawn_link in the gen_server:init was
because the init seemed to be run from an independent process that stopped,
which killed the loop. The internals of gen_server are a bit of a mystery to
me. Does this sound accurate?
I'm making my server an application, and adding supervision, so I thought I
should fix this at the same time. I guess I could spawn_link the recv_loop
in the gen_server api (eg if module aplio is a geb_server, then
aplio:start_link() could start the loop and the gen_server) but the loop is
related to the gen_server, not the parent process, so it doesn't sound right
to me.
All help appreciated.
/Bruce
More information about the erlang-questions
mailing list