[Libwebsockets] help on wsi pointer usage outside http callback

이성훈(Sunghoon Lee) sh1559.lee at hanwha.com
Thu Nov 28 11:53:16 CET 2019


Hello,



Below is what I have written before.

https://libwebsockets.org/pipermail/libwebsockets/2019-November/008154.html



Thank you for the kind reply before. I have not learned how to reply in the mailing list yet.



I have several additional questions.

I am currently porting libwebsockets into the my existing server.



https://libwebsockets.org/pipermail/libwebsockets/2014-September/001357.html

This link says that wsi should be handled only inside callback.


1.     Can I deliver/pass “wsi” pointer received from my http callback to other threads and call lws_write(wsi, …) in those other threads like below? Is wsi pointer thread safe?

I observe a crash sometimes inside lws_write which is hard to find the reason.

lws_write(wsi_pointer,

(unsigned char *)(buffer+LWS_SEND_BUFFER_PRE_PADDING),

Buffer Length,

LWS_WRITE_BINARY);


2.     Let's assume that using wsi pointer is allowed to access from other thread.

Then, I'd like to close client connection from different threads in my streaming server instead of closing it from the inside of my http callback.

How can I close a specific client from other threads which are different from my http callback.


3.     Let's again assume that using wsi pointer is allowed to access from other thread.

Do I have to monitor writable status of the wsi from http callback and let other threads know that and call lws_write from other threads?



Is there any way which I can use like (xxx.revents &POLLOUT) from different threads through wsi pointer?


4.     If inside lws_xxx function crashes, how do you usually debug?


(P.S: I don’t know how to add additional question in the added answer. Please teach me how to do that as well :))

Best Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20191128/cf8db71f/attachment.htm>


More information about the Libwebsockets mailing list