Skip to content

polling thread is never joined #6

hntrmrrs opened this Issue Apr 18, 2011 · 3 comments

2 participants


From the Erlang documentation for erl_drv_thread_create via enif_thread_create1:


All created threads need to be joined by the driver before it is unloaded.
If the driver fails to join all threads created before it is unloaded, the
runtime system will most likely crash when the code of the driver is unloaded.

I am not entirely sure if this warning applies to enif_thread_create as well, but the documentation seems to indicate that it would. I wanted to see if you had any feedback before I try to patch the code to support joining the polling thread. I think it will be useful when adding upgrade support to the erlzmq and erlzmq_nif modules.

evax commented Apr 18, 2011

Thanks again for your feedback.
You're right, we need to join the polling thread, but the code as it is needs refactoring.
Active sockets and sockets involved in a deferred operation will be closed automatically on erlzmq:term, but passive sockets are not handled this way yet, so there's still the risk having zmq_term blocking.
We need to keep track of passive sockets so that we can close them on erlzmq:term too, and safely join the polling thread without risking blocking the VM.


Ok, I am glad that I wasn't missing something. I am happy to work on refactoring the passive socket code. Is anybody else currently working on it whose feet I might step on?

evax commented Apr 18, 2011

Not that I know of, your contribution is welcome !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.