EldoS | Feel safer!

Software components for data protection, secure storage and transfer

SFTPserver crashing when client closed

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#12085
Posted: 01/11/2010 05:19:47
by Marcelo Danelon (Standard support level)
Joined: 01/08/2010
Posts: 2

When using samples SFTP server and SimpleSftpclient, I notice that when I end the client closing the window, the servers crashes with a access violation error. I believe the problem is related with the way server is treating this closing, and if I'm not wrong a calling like :

TSSHServerThread(lvConnections.items[I].Data).Terminate;

in the TfrmMain.RemoveClientFromList procedure , before

lvConnections.Items.Delete(I);

should fix it. Is this OK ? Sorry if this sounds very basic, but I`m newbie in this kind of application. .
#12088
Posted: 01/11/2010 17:41:06
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Hi. Thank you for pointing us at this issue.
It's not that way - all server threads must be terminated in .Finalize method.
However, RemoveClientFromList() should also check for FFinalizing flag, i.e. should be changed to:
Code
procedure TfrmMain.ServerThreadConnClosed(Sender: TObject);
begin
  if not FFinalizing then
    RemoveClientFromList(TSSHServerThread(Sender));
end;


But, this approach also causes another error, which we are investigating at the moment.
#12096
Posted: 01/12/2010 11:16:46
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Hi again.
You also need to add some other changes to code:
Code
ServerThread.pas, TSSHServerThread.Destroy:
Move lines
  if FSSHServer.Active then
    FSSHServer.Close(true);
to the top (just right after 'begin')

MainForm.pas, TfrmMain.Finalize:

change cycle below to:
  for I := 0 to Length(Thr) - 1 do
  begin
    Thr[I].FreeOnTerminate := false;
    Thr[I].Terminate;
    Thr[I].WaitFor;
    Thr[I].Free;
  end;

Reply

Statistics

Topic viewed 878 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!