* * *

Author Topic: lNet eventer in thread  (Read 246 times)

Max V. Terentiev

  • New member
  • *
  • Posts: 21
lNet eventer in thread
« on: May 17, 2018, 05:44:16 pm »
Hi,

I Implementing linux daemon and I need to use several lNet sockets for Http and Smtp operations.

Because daemon app not have main loop like gui app I create EventerThread like this:

Code: Pascal  [Select]
  1. consturtor TMyEventerThread.Create;
  2. begin
  3. MyEventer := BestEventerClass.Create; // for Linux epoll eventer will be created
  4. Inherited Create(false);
  5. end;
  6.  
  7. procedure TMyEventerThread.Execute;
  8. begin
  9.   while not Terminated do
  10.     begin
  11.     if not MyEventer.CallAction then
  12.       Sleep(10);
  13.     end;
  14. end;
  15.  
  16. procedure TMyDaemonClass.SomeProc;
  17. var
  18.   Http:TLHttp
  19. begin
  20.   Http:=TLHttp.Create;
  21.   Http.Eventer:=MyEventerThread.MyEventer; // assign shared eventer from eventer thread
  22.   // do some work
  23. end;
  24.  

But I have random AV/SIGSEGV errors in random places of lNet library.

In gui app where I call MyEventer.CallAction from Application.OnIdle same code works fine. But in thread I have big problems (

How to proper use lNet in daemon/threads ?

Please help !

Max V. Terentiev

  • New member
  • *
  • Posts: 21
Re: lNet eventer in thread
« Reply #1 on: May 18, 2018, 01:37:33 am »
Sorry, it's my fault ! I forgot to use critical section in some place. All works fine !


 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus