Does our TSynThread patch fix the issue you were talking about?
]]>In FPC is called Terminate and WaitFor but in other conditions (SysDestroy method):
if FHandle<>0 then
begin
{ Don't check Suspended. If the thread has been externally suspended (which is
deprecated and strongly discouraged), it's better to deadlock here than
to silently free the object and leave OS resources leaked. }
if not FFinished {and not Suspended} then
begin
Terminate;
{ Allow the thread function to perform the necessary cleanup. Since
we've just set Terminated flag, it won't call Execute. }
if FInitialSuspended then
Start;
WaitFor;
end;
end;
It should fix the problem at higher level.
See http://synopse.info/fossil/info/265f6a043b
destructor THttpApiServer.Destroy;
var i: integer;
begin
{.$ifdef LVCL}
Terminate; // for Execute to be notified about end of process
WaitFor;
{.$endif}
fHttpServer.Terminate;
fHttpServer.WaitFor;
in destructor TSQLHttpServer.Destroy; in mORMotHttpServer before
FreeAndNil(fHttpServer);
fixes the problem for FPC.
]]>Sounds like if a class instance is released twice, or not released in the expected order.
Try to run the server with FastMM4 FullDebugMode, which would help identify the problem.
See http://wiert.me/2009/07/29/delphi-fastm … roduction/
That would be nice but FastMM4 don't work for FPC Windows target . I can't test it for Linux, the linux version of my server is in progress :\
]]>Try to run the server with FastMM4 FullDebugMode, which would help identify the problem.
See http://wiert.me/2009/07/29/delphi-fastm … roduction/
with TSQLite3HttpService.CreateAsConsole do
try
DoStart(nil);
writeln(#10'Background server is running.'#10);
writeln('Press [Enter] to close the server.'#10);
ConsoleWaitForEnterKey; // ReadLn if you do not use main thread execution
exit;
finally
Free;
end
During server closing (only when the client is still trying to communicate with server), I have very often strange error in 3 ways (i think it is all related to some mORMot logic bug):
1 is raised in TSQLHttpServer.HttpThreadTerminate > TSQLRestServer.EndCurrentThread, line 38290 :
if Sender.ThreadID<>CurrentThreadId then
raise ECommunicationException.CreateUTF8(
'%.EndCurrentThread(%.ID=%) should match CurrentThreadID=%',
[self,Sender,Sender.ThreadID,CurrentThreadId]);
2 VarRecToTempUTF8 in SynCommons - SIGSEGV for this:
vtObject: begin
if V.VObject<>nil then begin
Res.Text := PUTF8Char(PPointer(PPtrInt(V.VObject)^+vmtClassName)^)+1;
3 for procedure in RTL - TThread.SysDestroy; / TThread.Synchronize; (classes module)
always is raised randomly one of above errors. In Delphi all works fine...
This time I have no idea what is wrong :\
]]>