![]() This is a huge patch that should be a global NOP. For unix type platforms it enables -Wconversion to issue warnings (-> error) for all automatic casts that seem less than ideal but are normally concealed by the toolchain. This is things like passing an int to a size_t argument. Once enabled, I went through all args on my default build (which build most things) and tried to make the removed default cast explicit. With that approach it neither change nor bloat the code, since it compiles to whatever it was doing before, just with the casts made explicit... in a few cases I changed some length args from int to size_t but largely left the causes alone. From now on, new code that is relying on less than ideal casting will complain and nudge me to improve it by warnings. |
||
---|---|---|
.. | ||
mount-origin | ||
CMakeLists.txt | ||
minimal-ws-server.c | ||
protocol_lws_minimal.c | ||
README.md |
lws minimal ws server (threads) + SMP
This demonstrates both independent threads creating content as in the -threads example, and multiple service threads as in the http-server-smp example (but with ws).
build
You must first build libwebsockets itself with cmake -DLWS_MAX_SMP=8
or some other number greater than one.
$ cmake . && make
Pthreads is required on your system.
usage
$ ./lws-minimal-ws-server-threads-smp
[2019/01/28 06:59:17:4217] USER: LWS minimal ws server + threads + smp | visit http://localhost:7681
[2019/01/28 06:59:17:4219] NOTICE: Service threads: 2
[2019/01/28 06:59:17:4220] NOTICE: LWS_CALLBACK_EVENT_WAIT_CANCELLED in svc tid 0x7fec48af8700
[2019/01/28 06:59:17:4220] NOTICE: LWS_CALLBACK_EVENT_WAIT_CANCELLED in svc tid 0x7fec48af8700
...
Visit http://localhost:7681 on multiple browser windows. You may need to open 4 before the second service thread is used (check "svc tid" in the browser output).
Two lws service threads are started.
Two separate asynchronous threads generate strings and add them to a ringbuffer, signalling all lws service threads to send new entries to all the browser windows.
This demonstrates how to safely manage asynchronously generated content and hook it up to the lws service threads.