[fpc-devel] daemonapp 100% cpu easting fix

Michael Van Canneyt michael at freepascal.org
Sat Nov 17 13:46:19 CET 2007



On Sat, 17 Nov 2007, Mattias Gaertner wrote:

> On Sat, 17 Nov 2007 10:12:30 -0200
> Steve Howe <howesteve at gmail.com> wrote:
> 
> > Hello all,
> > 
> > While using the daemonapp.pp unit to code a daemon, I've found that 
> > applications that it eat 100% of the CPU. After tracking and
> > debugging, I've found out that the problem is in the daemonapp's
> > TDaemonThread.Execute() method:
> > 
> > procedure TDaemonThread.Execute;
> > 
> > begin
> >   If FDaemon.Start then
> >     begin
> >     FDaemon.Status:=csRunning;
> >     StartServiceExecute;
> >     if not FDaemon.Execute then
> >       begin
> >       While Not Terminated do
> >         CheckControlMessage(True);
> >       CheckControlMessage(False);
> >       end;
> >     end;
> > end;
> > 
> > The loop has no interval so it just consumes all free CPU. 
> 
> Then CheckControlMessage has a bug. The 'True' means it should wait for
> the next message.
> But I see no 'virtual' and no code in this function - strange (fpc
> 2.3.1).

You are right, I committed the 'fix' as initially proposed, but moved it to
the unix version of the CheckControlMessage; 

Checking for this message is not yet implemented on unix. The idea is to open a
'control' socket using simpleIPC and to check on this socket for a message.

Michael.



More information about the fpc-devel mailing list