On 10/05/2017 20:16, Evgeny Grin wrote:
On 10.05.2017 11:21, Dom F wrote:
I'm using MHD versions 0.9.54 and latest from git on both FreeBSD 11 and
Linux (I think CentOS 7 with v3.10 kernel).
No extra args to ./configure on Linux.
HTTPS,  gnutls and libgcrypt related args to ./configure on FreeBSD.

My MHD_UpgradeHandler creates a new thread, immediately detached, which
does the following:

Put socket into blocking mode
Loop doing read() and processing received data until error, EOF or
"close" websocket frame
Call MHD_upgrade_action(urh, MHD_UPGRADE_ACTION_CLOSE)
Exit thread

It is also possible that I might call "shutdown(sock, SHUT_RDWR)" from
another thread to cause above loop to exit.
By your shutdown() of socket you breaking MHD internal processing.
It mostly relevant to HTTPS processing, didn't recheck HTTP code.
But I suggest you do not shutdown "upgraded" socket.
Probably we need to update documentation to reflect it.

Could you try without shutdown() of socket?

OK, I replaced my calls to shutdown() with a debug message and turned on MHD_USE_THREAD_PER_CONNECTION again. Currently I am seeing approx. 55 active websocket threads but daemon->connections is up to around 1450. Looking at my logfile there were only about 4 times my code would have called shutdown() anyway. Also, I'm NOT using MHD_USE_TLS or any HTTPS-related MHD flag. (daemon->options is 42061)

Hope this helps narrow down the issue! I can also very easily test if you want to throw more suggestions or patches my way.

Dom

Reply via email to