[Libwebsockets] Repetitive LWS_CALLBACK_SERVER_WRITABLE making cpu load 99%

Shmuel Weiss sweiss at kramerel.com
Thu Jun 30 01:17:55 CEST 2016

I have to check, I am not using neither compiling the testserver.
Tell me if the flow is as following:

My Main loop is doing the following:

	For all my protocol do:
		lws_callback_on_writable_all_protocol(context, protocol);

	lws_service(context,timeout); ===> here it is no more waiting.

My LWS Callback is doing:

	Read the data send and send it to the main engine for processing

If lws_partial_buffered != 1
	Check if there is something to send from the main engine and send it

I expected to have ONWRITE called each time lws_service returns after timeout, but it never blocks (except at startup until the first ONREAD happen).

-----Original Message-----
From: Andy Green [mailto:andy at warmcat.com] 
Sent: Thursday, June 30, 2016 00:11
To: Shmuel Weiss; libwebsockets at ml.libwebsockets.org
Subject: Re: [Libwebsockets] Repetitive LWS_CALLBACK_SERVER_WRITABLE making cpu load 99%

On Wed, 2016-06-29 at 20:02 +0000, Shmuel Weiss wrote:
> Hi Andy,
> A new phenomena.
> The  LWS main thread is quiet until I initiate the first connection, 
> where sending data and receiving data is OK but since this moment the 
> lws_service function doesn’t block until timeout and process 
> immediately even if no data arrived.
> What I missed ?

Does the test server, without your code, act like that?


> My lws callback return 0 , should I return -1 ?
> thanks
> This mail was sent via Mail-SeCure System.
>  _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://libwebsockets.org/mailman/listinfo/libwebsockets
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20160629/f82b0bff/attachment-0001.html>

More information about the Libwebsockets mailing list