Closed tomski-spqr closed 4 weeks ago
Thanks for the heads-up. It seems like it might be related to the select()
call. Could you please run it with strace
and let me know which call is consuming all the CPU?
On holiday for a while, hence the delay :-)
poll([{fd=3, events=POLLIN}, {fd=4, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=0}], 5, -1) = 1 ([{fd=8, revents=POLLERR}])
Seems fd=8 (I guess this the file descriptor from out.fifo) causes a POLLERR
Probably the FIFO must be closed and re-opened when the reader (cat in this case) disconnects. I will check again after my holiday.
Fixed with attached patch. 2024-08-11-fix-high-cpu.patch.gz
I completely overlooked this update. Thanks for submitting the patch! I’ve pushed it upstream, and it will be included in the next release.
Started gwsocket with:
./gwsocket --pipein=in.fifo --pipeout=out.fifo
Open a console and do:
cat out.fifo
Connect with the test html application to the websocket and send an "Hello world" message. --> The message is printed on the console as expected.
Break
(CTRL-C)
the cat command.As soon as I stop the cat command (and thus disconnect from the pipe), the CPU usage of gwsocket jumps to almost 100%