#1 2021-04-05 18:42:15

damiand
Member
From: Greece
Registered: 2018-09-21
Posts: 94

TSynDaemon.Stop is called twice

I've noticed when running a TSynDaemon program with --console parameter on Linux that the method Stop is called twice when I press  [Enter] to quit. This raised an AV Exception in method implementation as the following:

procedure TBareDaemon.Stop;
begin
    fHttpServer.Free;
    fServer.Free;
end;

and I had to rewrite it as follows:

procedure TBareDaemon.Stop;
begin
  if fHttpServer <> nil then
  begin
    fHttpServer.Free;
    fHttpServer := nil
  end;
  if fServer <> nil then
  begin
    fServer.Free;
    fServer := nil
  end;
end;

I got this AV Exception also in sample "37 - FishShop Service", for the same reason.

Offline

#2 2021-04-05 18:49:04

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: TSynDaemon.Stop is called twice

It is clearly documented as such:

    /// inherited class should override this abstract method with proper process
    // - should do nothing if the daemon was already stopped
    procedure Stop; virtual; abstract;

Offline

Board footer

Powered by FluxBB