FPC 3.2.2.
FServer is a TFPHTTPServer.
FServer.Active:=true never returns (as expected).
In Linux I hooked SIGINT/SIGTERM (with fpsignal) to do
FServer.Active:=false, in windows the same but using SysSetCtrlBreakHandler.
Under both windows and linux the server stops accepting requests but the
previous call to FServer.Active:=true still doesn't return and
FServer.free hangs.
With windows I can connect to the server to unlock it, e.g.
FServer.Active:=false;
TInetSocket.Create('127.0.0.1',FPort,1000).Free;
but this workaround doesn't work in Linux.
Deepseek came up with this solution:
FServer.AcceptIdleTimeout:=1000;
FServer.OnAcceptIdle:=@HandleAcceptIdle;
TMyClass.HandleAcceptIdle(Sender:TObject);
begin
if FStopRequested then
FServer.Active:=false;
end;
and in the signal handler I just set FStopRequested to true.
Is this the only way?
Bye
--
Luca
_______________________________________________
fpc-pascal maillist - [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal