[Libwebsockets] Tight loop 100% CPU with [SSL_connect WANT_... retrying]

Andy Green andy at warmcat.com
Tue Nov 24 01:42:40 CET 2015

On 23 November 2015 19:46:17 GMT+08:00, Andrejs Hanins <andrejs.hanins at ubnt.com> wrote:
>	I'm getting 100% CPU load when LWS client in SSL mode is connecting to
>some TCP port which accepts connection at TCP level but doesn't respond
>to SSL "Client hello". It typically happens when server process is very
>busy or hanged (I test with kill -stop PID). LWS client log outputs
>lots of "SSL_connect WANT_... retrying" messages which seem to come
>without any delay, so causing 100% CPU. Also for each such message I
>events set, however current events are already set for POLLIN and
>	Isn't 100% CPU load is something which should not happen in this
>situation? Any suggestions to avoid it? It is quite frustrating that
>clients which try to connect to busy servers eat 100% CPU.

Yes... that's why there are so many states around the connection, so it can go back to the event loop and pick it up when something happens.

Wanting read is difficult though.  Openssl may want to read something, but he may not be able to succeed at that until he has written something, eg, update keys.  That's why it's spinning he is writeable, but this time that wasn't the problem.

He should timeout though on client side.

I'll take a look at it tonight.


>	Thanks in advance!
>BR, Andrey
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org

More information about the Libwebsockets mailing list