libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] Lots of CPU usage with MHD_USE_POLL


From: Boyan Kasarov
Subject: Re: [libmicrohttpd] Lots of CPU usage with MHD_USE_POLL
Date: Tue, 09 Feb 2010 16:59:34 +0200

Hello,

I just checked out revision 10259 from 2010-02-08 13:04:58 +0200 at
https://ng.gnunet.org/svn/libmicrohttpd

Yes, one of the calls to poll() is with argument 1000, the one that is
called from the spawned thread that handles new connection, aka
MHD_handle_connection() in src/daemon/daemon.c:567.

But there is another call to poll(), that I addressed, it is called on
the accept socket from MHD_poll() function in src/daemon/daemon.c:1073.

Here is a quick diff that will make it also to 1000:

Index: src/daemon/daemon.c
===================================================================
--- src/daemon/daemon.c (revision 10259)
+++ src/daemon/daemon.c (working copy)
@@ -1070,7 +1070,7 @@
   p.events = POLLIN;
   p.revents = 0;
 
-  if (poll(&p, 1, 0) < 0) {
+  if (poll(&p, 1, 1000) < 0) {
     if (errno == EINTR)
       return MHD_YES;
 #if HAVE_MESSAGES


Thanks,
Boyan

В 09:10 +0100 на 09.02.2010 (вт), Christian Grothoff написа:
> Hi Boyan,
> 
> I don't know what version of MHD you are talking about, but in both SVN HEAD 
> and MHD 0.4.5 (the only released version with support for poll), the third 
> argument given to 'poll' is already "1000".
> 
> Best,
> 
> Christian
> 
> On Monday 08 February 2010 09:31:15 Boyan Kasarov wrote:
> > Hello,
> > 
> > I noticed that in function:
> > 
> > static int
> > MHD_poll (struct MHD_Daemon *daemon)
> > {
> > ...
> >     if (poll(&p, 1, 0) < 0) {
> > ...
> > }
> > 
> > The timeout for poll() call is 0 milliseconds, so the call does not
> > block at all, which causes lots of CPU usage.
> > 
> > As a workaround I changed the timeout from 0 to 1000 (1 second) and it
> > works fine for me.
> > 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]