Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polling thread is never joined #6

Open
hntrmrrs opened this issue Apr 18, 2011 · 3 comments
Open

polling thread is never joined #6

hntrmrrs opened this issue Apr 18, 2011 · 3 comments

Comments

@hntrmrrs
Copy link

From the Erlang documentation for erl_drv_thread_create via enif_thread_create1:

Warning

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
Copy link
Contributor

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.

@hntrmrrs
Copy link
Author

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
Copy link
Contributor

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants