chuckremes / ffi-rzmq

FFI bindings for ZeroMQ so the library can be used under JRuby and other FFI-compliant ruby runtimes
242 stars 62 forks source link

question on proper shutdown #103

Closed jhoblitt closed 10 years ago

jhoblitt commented 10 years ago

This is purely an informational request about the correct usage of the ruby bindings.

The official "ruby" examples for interrupt trapping suggest that open sockets need to be manually #closed before releasing the context, similar to the C/C++ API.

https://github.com/imatix/zguide/blob/cb8b3d5ebebcf1282d9d9568c5e3427e5724863d/examples/Ruby/interrupt.rb#L8

However, I believe that may not be necessary as it looks like invoking #terminate on the context will #close the sockets for you. https://github.com/chuckremes/ffi-rzmq/blob/master/lib/ffi-rzmq/context.rb#L123-L125

Is that correct or am I missing something?

chuckremes commented 10 years ago

The code that you pointed at handles termination of the Context when that object is garbage collected. Currently we do not track open sockets. You need to handle this manually.

On Nov 25, 2013, at 12:06 PM, Joshua Hoblitt notifications@github.com wrote:

This is purely an informational request about the correct usage of the ruby bindings.

The official "ruby" examples for interrupt trapping suggest that open sockets need to be manually #closed before release the context, similar to the C/C++ API.

https://github.com/imatix/zguide/blob/cb8b3d5ebebcf1282d9d9568c5e3427e5724863d/examples/Ruby/interrupt.rb#L8

However, I believe that may not be necessary as it looks like invoking #terminate on the context will #close the sockets for you. https://github.com/chuckremes/ffi-rzmq/blob/master/lib/ffi-rzmq/context.rb#L123-L125

Is that correct or am I missing something?

— Reply to this email directly or view it on GitHub.

jhoblitt commented 10 years ago

Thank you for straightening that out. Is it worth me sending a blurb about that for the readme?

chuckremes commented 10 years ago

It can't hurt! Documentation is always important, so if you have some notes that you think would clarify things then please send them on. I love pull requests.

On Nov 25, 2013, at 5:52 PM, Joshua Hoblitt notifications@github.com wrote:

Thank you for straightening that out. Is it worth me sending a blurb about that for the readme?

— Reply to this email directly or view it on GitHub.