SftpSubsystem instances are created in HostedServer inside InitializeSftp.
At the same time these lines are called:
channel.DataReceived += (ss, ee) => sftpsub.OnInput(ee);
sftpsub.OnOutput += (ss, ee) => channel.SendData(ee);
sftpsub.OnClose += (ss, ee) => channel.SendClose(null);
I assume adding event handlers without removing them when the channel is closed will prevent disposing the sftpsub references.
adding this and making sure CloseReceived is called from Channel should do it:
channel.CloseReceived += (ss, ee) =>
{
channel.DataReceived -= (ss, ee) => sftpsub.OnInput(ee);
sftpsub.OnOutput -= (ss, ee) => channel.SendData(ee);
sftpsub.OnClose -= (ss, ee) => channel.SendClose(null);
sftpsub.Dispose(); // is this needed? It will force all open file handles to be released
};
};
SftpSubsystem instances are created in HostedServer inside InitializeSftp. At the same time these lines are called: channel.DataReceived += (ss, ee) => sftpsub.OnInput(ee); sftpsub.OnOutput += (ss, ee) => channel.SendData(ee); sftpsub.OnClose += (ss, ee) => channel.SendClose(null);
I assume adding event handlers without removing them when the channel is closed will prevent disposing the sftpsub references.
adding this and making sure CloseReceived is called from Channel should do it: channel.CloseReceived += (ss, ee) => { channel.DataReceived -= (ss, ee) => sftpsub.OnInput(ee); sftpsub.OnOutput -= (ss, ee) => channel.SendData(ee); sftpsub.OnClose -= (ss, ee) => channel.SendClose(null); sftpsub.Dispose(); // is this needed? It will force all open file handles to be released }; };