[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:

while(running)
{
	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:

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

ONWRITE:
If lws_partial_buffered != 1
	Check if there is something to send from the main engine and send it
Else
 	lws_callback_on_writable();


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?

-Andy

> 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