[Libwebsockets] libwebsocket message loop thread take 100% of the CPU

Nagendra Kumar Goel (नगेन्द्र गोयल) nagendra.goel at gmail.com
Mon Aug 24 17:58:52 CEST 2020


What I have specifically seen is that we have a number of worker threads
that handle incoming web requests (on the LWS based server) and the main
thread has the message processing. The main thread would normally consume
0-1% CPU. However very occasionally (let's say after 10 days of uptime) It
would start consuming 100% CPU. Then we have to restart the program to get
it back to 0% CPU  usage. I have not yet identified the source of this
problem. Interestingly only one binary displays this behavior, and
attaching a gdb to the process and pausing it takes me to a join()
statement.

On Mon, Aug 24, 2020 at 11:06 AM Andy Green <andy at warmcat.com> wrote:

>
>
> On 8/24/20 4:00 PM, Peiffer Eric wrote:
> > Hi,
> >
> > I have an application that open thousand of clients websocket and use
> > the default event loop poll().
> > The thread that run the event loop execute only the following line of
> code:
> >
> > while (n >= 0 && !interrupt) {
> >        n = lws_service(context, 0);
> > }
> >
> > This work well, but sometimes this thread  take 100% of the CPU and no
> > more callback is called.
> >
> > Has anyone ever had this behaviour?
>
> If it's spinning somewhere, you are going to have to find out where (eg,
> attach with gdb -p and ctrl-c step it), or provide a way to reproduce it.
>
> Asking "does it normally drop dead and spin somewhere?", the answer is
> "no".
>
> But lws is a library, a coproduction between its code and your code, if
> in your user code you do things like call lws apis from other threads
> illegally you can trash its internal state pretty quickly.
>
> -Andy
>
> > Regards,
> >
> > Eric Peiffer
> >
> >
> >
> >
> > .
> >
> > _______________________________________________
> > Libwebsockets mailing list
> > Libwebsockets at ml.libwebsockets.org
> > https://libwebsockets.org/mailman/listinfo/libwebsockets
> >
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20200824/831586da/attachment-0001.htm>


More information about the Libwebsockets mailing list