From 6c61c2169e635bcf100e128096f66a9334035c7b Mon Sep 17 00:00:00 2001 From: Stefan Grundmann Date: Wed, 1 Sep 2010 19:42:57 +0200 Subject: fix process leak in ssh_system_sup (dynamicaly created childs where not cleaned up) 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. --- lib/ssh/src/ssh_connection_manager.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/ssh/src/ssh_connection_manager.erl') diff --git a/lib/ssh/src/ssh_connection_manager.erl b/lib/ssh/src/ssh_connection_manager.erl index 9e55312e5f..6bf89224cf 100644 --- a/lib/ssh/src/ssh_connection_manager.erl +++ b/lib/ssh/src/ssh_connection_manager.erl @@ -560,13 +560,18 @@ handle_info({'EXIT', _, _}, State) -> %% The return value is ignored. %%-------------------------------------------------------------------- terminate(Reason, #state{connection_state = - #connection{requests = Requests}, + #connection{requests = Requests, + sub_system_supervisor = SubSysSup}, opts = Opts}) -> SSHOpts = proplists:get_value(ssh_opts, Opts), disconnect_fun(Reason, SSHOpts), (catch lists:foreach(fun({_, From}) -> gen_server:reply(From, {error, connection_closed}) end, Requests)), + Address = proplists:get_value(address, Opts), + Port = proplists:get_value(port, Opts), + SystemSup = ssh_system_sup:system_supervisor(Address, Port), + ssh_system_sup:stop_subsystem(SystemSup, SubSysSup), ok. %%-------------------------------------------------------------------- -- cgit v1.2.3