[Libwebsockets] multithreading

Andy Green andy at warmcat.com
Thu Nov 21 17:26:57 CET 2019



On 11/21/19 3:58 PM, Peiffer Eric wrote:
> Hi,
> 
> I'm new in libwebsockets. I'm test some code examples, And read the 
> documentation and README files.
> My question is very simple:
> 
> Is it thread safe to call:
> 
> lws_callback_vhost_protocols_vhost(vhost,LWS_CALLBACK_USER,NULL,0);
> 
> from another thread that the thread that run lws_service(context)?

No... basically nothing is unconditionally threadsafe except use 
lws_cancel_service()

https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c#n120

https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c#n262

This is safe on different event loops etc.

-Andy

> Regards,
> 
> Eric Peiffer.
> 
> 
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets
> 


More information about the Libwebsockets mailing list