[Libwebsockets] Issue with LWS_CALLBACK_GET_THREAD_ID

Hemant Kumar hkumar at arubanetworks.com
Wed Sep 2 20:10:56 CEST 2015


Hi

I have written a LWS client in which I am starting libwebsocket context in a different thread than the main thread. Whenever it is time to send data , I call callback_on_writable() .

What I am observing is LWS_CALLBACK_GET_THREAD_ID is used in calling my callback repeatedly before it does the write operation. This is a heavy overhead on my application.
Is there any way ,I can avoid this? I am doing return pthread_self for this case of  LWS_CALLBACK_GET_THREAD_ID  in my callback but nothing happens.


Also, I see many a times, my callback is called after a sequence of external polling support reasons. I am not using external polling and this is client application which is sending async data.
Not receiving anything on socket but picking up data from queue.

Any input is welcome, I digged some of the emails on mailing list but couldn't find good reason to resolve my issues.


Thanks and Regards
Hemant

On 05/26/2014 02:53 PM, Micka wrote:
> Hi,
>
> I wanted to know if it's normal that in my protocol function I received
> a lot of LWS_CALLBACK_GET_THREAD_ID
>
> It happens all the time .....

Yes it's normal, it's used to understand if you're asking for a
writeable callback from another thread.

It shouldn't be happening if your system is otherwise idle, lws CPU
should be like 0%.

But if your server is active you'll be getting these when it does
something.  pthread_self should be really cheap though.

-Andy

> that is my return :
>
>     return pthread_self();
>
> And I don't use that :
> /*
> * if you will call "libwebsocket_callback_on_writable"
> * from a different thread, return the caller thread ID
> * here so lws can use this information to work out if it
> * should signal the poll() loop to exit and restart early
> */
>
>
> Thx,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libwebsockets.org/pipermail/libwebsockets/attachments/20150902/9e641111/attachment.html>


More information about the Libwebsockets mailing list