ASPLes / nopoll

OpenSource WebSocket toolkit
http://www.aspl.es/nopoll
GNU Lesser General Public License v2.1
126 stars 73 forks source link

Fix race condition between ssl handshake and loop event #74

Closed mwik closed 1 year ago

mwik commented 1 year ago

When connecting to an SSL/TLS site and at the same time using the nopoll_loop_wait() event loop there is a race condition between the event loop waking up and reading from the socket and the SSL_Connect() loop. If the event loop reads the socket first, before SSL_Connect() is done with the ssl handshake the ssl handshake to fails.

This patch is an attempt at fixing that race condition by introducing a check so that the event loop is not listening on ssl sockets before the ssl handshake is done.

francisbrosnan commented 1 year ago

Hello Mårten, Thanks for reporting. Patch looks good, merging.. Best Regards