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

Jayson Vantuyl kagato@REDACTED
Mon Sep 21 21:43:38 CEST 2009


Unlinking is bad mostly because you can leak processes.  One of the  
advantages of the supervision tree is that you can guarantee that all  
children get killed when restarts happen.

I would recommend having the reconnection process always running, and  
have the gen_server send it an async message every time the connection  
is down and there is a pending request, maybe on a timeout.

On Sep 21, 2009, at 10:42 AM, Sergey Samokhin wrote:

> Hello.
>
> I'm trying to make my wrapper around epgsql more tolerant of network
> outages. When my gen_server detects that connection has been lost, a
> special process is created to make a connection in an asynchronous
> manner (I want to handle calls to the server, so I can't block in
> reconnect function). When connection is established, pid is sent back
> to the gen_server and 'connector' process is unlinked from the pid.
>
> Are there any pitfalls of unlinking from working gen_fsm? Does gen_fsm
> store parent id anywhere into the state?
>
> I haven't found using of the parent process's id in the epgsql  
> sources.
>
> P.S. I see another way to implement smoothly reconnects without
> blocking gen_server: by using erlang:start_timer/3 in the gen_server.
> I haven't decided yet which way is better =)
>
> Thanks.
>
> -- 
> Sergey Samokhin
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>



-- 
Jayson Vantuyl
kagato@REDACTED







More information about the erlang-questions mailing list