[erlang-questions] simple_one_for_one supervisor - what happens at restart? (also: gen_tcp)
Fri May 13 15:47:17 CEST 2016
There is no point supervising a process which is handling a TCP connection
as even if the supervisor restarts this process, the socket will not be
reinstated. You just have to spawn a new process which will stay alive as
long as the connection is active. Once the TCP connection is lost, the
process dies, and a new process is spawned when the client reconnects.
for a barebones example.
On 13 May 2016 at 14:25, Oliver Korpilla <Oliver.Korpilla@REDACTED> wrote:
> I have transient workers under a simple_one_for_one supervisor. I start
> them dynamically through start_child/2.
> How exactly do these get restarted? With the same parameter list I
> supplied when first starting them?
> Concrete example:
> I have a central process listening to a TCP port, then accepting a
> connection, creating a worker for it through a supervisor, and then using
> gen_tcp:controlling_process/2 to transfer control of that new socket to the
> worker. The worker starts with one parameter: the socket.
> Now lets say the worker crashes on unexpected input and gets restarted. Is
> the socket now closed? Will the same socket again be provided to the
> process on restart?
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions