[erlang-questions] Is it safe to unlink from gen_fsm on the fly?

Sergey Samokhin prikrutil@REDACTED
Wed Sep 23 19:43:26 CEST 2009

Hello, Jayson!

> If you have the reconnection process always running, do you need to spawn it
> and pass it around?

No, I don't =)

> That said, you might be able to invert the scenario.  What if it was a
> gen_event?  They you could just throw off a synchronous event when you have
> a disconnection, and it could catch it to reconnect.

Which of the previously mentioned processes (gen_server, connector)
are you suggesting to be implemented as a gen_event?

Could you explain the picture with gen_event being used anyway in a
bit more details?

Assuming the connector is implemented as a gen_event, supervision
three should have one of the two following forms (hope, spaces won't
be skipped by ezmlm):

a) [iface] and [connector] are both linked to the supervisor:

              |       |
[iface gen_server] [connector gen_event]

b) connector is linked to the iface which in turn is linked to the supervisor:

[iface gen_server]
[connector gen_event]

Is any of those the solution you had in mind while writing about gen_event?

P.S. I have one more solution to note that hasn't been touched yet:
there is only one process - gen_server - trying to reconnect every
?TIME ms by handling messages sent using erlang:send_after(?TIME,
self(), reconnect). This way to reconnect can be considered as
"partially" blocking, because the gen_server is still able to react on
incoming message between 'reconnect' events. It's only useful when
connect() is relative fast.


Sergey Samokhin

More information about the erlang-questions mailing list