-
Notifications
You must be signed in to change notification settings - Fork 58
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
data ownership of zmq_msg_init_data #47
Comments
When I first wrote this, I was thinking that the |
Thanks for looking into this. That code scared the bejeezus out of me too when I was looking at it. It would be great if we can arrange for |
I'm not worried about The problem with |
I think the reason we haven't been bitten by this is that for sending strings or arrays in ØMQ version 3 or later, we currently use zmq_send, which doesn't use the |
However, I have a fix for the zero-copy |
Phenomenal. I'd love to simplify this API and getting better performance on top of that is a huge win. |
I'm wondering if the zero-copy version should be called |
Of course, the old way might still be safe as long as the user doesn't pass the |
So the There may be some opportunity for a |
Thinking a little more on it, I don't think that ZMQ.send(buf::Array{Uint8}) = ZMQ.send(Message(copy(buf))) or we could make it a blocking call instead. |
How about this:
|
I just pushed a possible solution to the zerocopy branch. |
Ping. |
Thanks for doing this. Sorry I missed your pings earlier – this looks (belatedly) very good. |
I was looking over the
Message
constructor code because of #46, and the call tozmq_msg_init_data
frightens me, especially inMessage(io::IOBuffer)
.According to the zmq_msg_init_data docs, this does not make a copy and "ØMQ shall take ownership of the supplied buffer". That makes it sound like terrible things will happen if Julia garbage-collects the data (e.g. the
IOBuffer
) before ØMQ is done with it. Maybe we've just been lucky so far?Options:
ObjectIdDict
or something, to prevent it from being garbage-collected. Use thezmq_free_fn
callback parameter tozmq_msg_init_data
to remove the data from the dict once ØMQ is done with it. Problem: the callback needs to be threadsafe, so it probably needs to just calluv_async_send
or something to tell Julia to gc the object once it wakes up.The text was updated successfully, but these errors were encountered: