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: Christian Grothoff
Subject: Re: [libmicrohttpd] Lots of CPU usage with MHD_USE_POLL
Date: Tue, 9 Feb 2010 20:31:47 +0100
User-agent: KMail/1.12.4 (Linux/2.6.31-14-generic; KDE/4.3.4; i686; ; )

Hi!

You're correct, that's a place where there should *also* be a 1000.  Fixed in 
SVN HEAD (10261).

Best,

Christian

On Tuesday 09 February 2010 03:59:34 pm Boyan Kasarov wrote:
> 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]