<div dir="ltr">Oliver: there is no restart for children under a simple 1-1 supervisor as documented under Supervision Principles at <a href="http://erlang.org/doc/man/supervisor.html#id243029">http://erlang.org/doc/man/supervisor.html#id243029</a><div><br></div><div>Otoh, I have to strongly disagree with Chandru about there being "no point" in supervising a connection process. Depending on the nature of your application, there can be a *huge* benefit in supervision, which is orderly shutdown. With a proper supervisory tree, you can ensure that all connection processes have a chance to finish their work and shut down cleanly when you stop your application.</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, May 13, 2016 at 8:47 AM Chandru <<a href="mailto:chandrashekhar.mullaparthi@gmail.com">chandrashekhar.mullaparthi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Oliver,<div><br></div><div>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.</div><div><br></div><div>See <a href="https://gist.github.com/cmullaparthi/18ba2219befbf7a3c44c28cab004456f" target="_blank">https://gist.github.com/cmullaparthi/18ba2219befbf7a3c44c28cab004456f</a> for a barebones example.</div><div><br></div><div>cheers,</div><div>Chandru</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 13 May 2016 at 14:25, Oliver Korpilla <span dir="ltr"><<a href="mailto:Oliver.Korpilla@gmx.de" target="_blank">Oliver.Korpilla@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello.<br>
<br>
I have transient workers under a simple_one_for_one supervisor. I start them dynamically through start_child/2.<br>
<br>
How exactly do these get restarted? With the same parameter list I supplied when first starting them?<br>
<br>
Concrete example:<br>
<br>
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.<br>
<br>
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?<br>
<br>
Thanks,<br>
Oliver<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div>