I'm playing with fphttpserver and wrote a test project following (loosely) that document:
https://www.freepascal.org/~michael/articles/webserver1/webserver1.pdfWhat I've noticed is that TThread.DoTerminate doesn't get called when you terminate thread in Windows.
But the way the embedded server was outlined into the Michael's document:
procedure THTTPServerThread.Execute;
begin
try
FServer.Active := True;
finally
FServer.Free;
end;
end;
procedure THTTPServerThread.DoTerminate;
begin
inherited DoTerminate;
FServer.Active := False;
end;
Since obviously
TFPHTTPServer.Active:=True is blocking and
TThread.DoTerminate isn't called, anyone have an idea how to terminate the server in a graceful way?
Edit: As a matter of fact TThread.DoTerminate was not executed in Linux either.
It seems that the Michael's example have an issue - FServer.Free won't get executed into the finally clause. Confirmed with heaptrc.
In that case the question becomes even more important. I guess it can be rephrased into: Does anyone know if it is safe to call :
TFPHTTPServer.Active:=False
from another thread?