#1 2021-11-29 10:19:34

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

EnterCriticalSection in Tsyslog causes http server+websockets to hang

Using a existing example I trying to create a websocket server:

srvinst:=TRestServerDB.Create(createRestModel); 
srvinst.Model.Owner:=srvinst;
....
srvinst.CreateMissingTables;
// register our ILongWorkService implementation as shared TLongWorkService
srvinst.ServiceDefine(TwbService,[IwbService],sicPerThread).ByPassAuthentication:=true;
try srv:=TRestHttpServer.Create('8888',[srvinst],'+',useBidirAsync);
srv.WebSocketsEnable(srvinst, websocketspass);
except on e:exception do begin result:=e.ClassName+'='+e.Message; exit; end; end;

Before the above code, logging is enabled with the following:

with TSynLog.Family do 
 begin 
  Level:=LOG_VERBOSE; 
  EchoCustom:=logmy2memo; 
 end;

where logmy2memo is just adding lines to a Tmemo in the main form

The server hangs before srv.WebSocketsEnable(srvinst, websocketspass);
The problem is from EchoCustom:=logmy2memo;

I try to debug it:
The problem starts from file mormot.net.async line 1663
log.Log(sllTrace, 'Create: started % threads', [fThreadPoolCount + 1], self);

If I comment the above the problem continues to exist in the file mormot.core.log line 4346
    EnterCriticalSection(GlobalThreadLock);

If I move EchoCustom:=logmy2memo after server starting I do not have this problem

Thank you in advance

Offline

#2 2021-11-29 10:28:40

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: EnterCriticalSection in Tsyslog causes http server+websockets to hang

If I move all log to a Tstringlist and add log output from this list to Tmemo after starting this problem does not exist

Offline

Board footer

Powered by FluxBB