[erlang-patches] fix process leak in ssh_system_sup (dynamicaly created childs where not cleaned up)

Attila Rajmund Nohl attila.r.nohl@REDACTED
Mon Sep 27 12:04:53 CEST 2010


Hello!

The sub_subsystem function looks like this in the R14B sources:

stop_subsystem(SystemSup, SubSys) ->
    case lists:keyfind(SubSys, 2, supervisor:which_children(SystemSup)) of
        false ->
            {error, not_found};
        {Id, _, _, _} ->
            spawn(fun() -> supervisor:terminate_child(SystemSup, Id),
                           supervisor:delete_child(SystemSup, Id) end),
            ok;
        {'EXIT', {noproc, _}} ->
            %% Already terminated; probably shutting down.
            ok;
        {'EXIT', {shutdown, _}} ->
            %% Already shutting down.
            ok
    end.

I think a catch is missing from the case...

2010/9/2, Niclas Eklund <nick@REDACTED>:
>
> Hello!
>
> Thanks for reporting this! I've added your patch and it will be included
> in R14B. I had to do some additional changes to avoid a race condition
> between some processes.
>
> Best regards,
>
> Niclas @ Erlang/OTP
>
> On Wed, 1 Sep 2010, Stefan Grundmann wrote:
>
>> The ssh_system_sup supervisor supervises one ssh_subsystem_sup process for
>> every client connection. There was no functionality to free resources
>> (terminate_child/ delete_child) when a client connection was closed.
>> Which lead to one ssh_subsystem_sup and one ssh_channel_sup process left
>> over.
>>
>> This commit adds ssh_system_sup:stop_subsystem/2 and code that calls it
>> in ssh_connection_manager:terminate/2.
>>
>> git fetch git://github.com/sg2342/otp.git fix_ssh_system_sup_proc_leak
>>
>> best regards
>>
>> Stefan Grundmann
>>
>> ________________________________________________________________
>> erlang-patches (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:erlang-patches-unsubscribe@REDACTED
>>
>
>
>
> ________________________________________________________________
> erlang-patches (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-patches-unsubscribe@REDACTED
>
>


More information about the erlang-patches mailing list