ASPLes / nopoll

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

Cannot call nopoll_conn_ref() within on_connection_ready() #43

Closed softins closed 6 years ago

softins commented 6 years ago

It appears that the on_connection_ready() hook is called from within nopoll_conn_complete_handshake() with the connection mutex held:

                /* acquire here handshake mutex */
                nopoll_mutex_lock (conn->ref_mutex);

                /* complete handshake */
                nopoll_conn_complete_handshake (conn);

                /* release here handshake mutex */
                nopoll_mutex_unlock (conn->ref_mutex);

The above code appears in two places: nopoll_conn_is_ready() and nopoll_conn_get_msg().

This means that it is impossible to call nopoll_conn_ref() within on_connection_ready(), due to deadlock.

Should there be a separate handshake_mutex, different from the ref_mutex?