[zeromq-dev] Question about the use of messages with allocated data (that gets freed)

Rick Flower nrf at ca-flower.com
Wed Jan 25 22:15:08 CET 2012

On 24.01.2012 20:05, Martin Sustrik wrote:

> I am not sure what the actual question is. When using
> zmq_msg_init_data() and subsequend zmq_send() you most drop all the
> references to the buffer and supply 0MQ with a deallocation function
> that it calls when it is done with sending to deallocate the buffer.

I think you answered my question.. I just was curious about the
use of zmq_msg_init_data() and the subsequent zmq_send() and whether
it might be 'done' sending prior to my function returning after the
zmq_send() comes back.. I believe I read that the send will queue it
up for sending and not block meaning my code may have control again
but the buffer may be sent behind the scenes sometime later possibly.
In my case I'm logging large buffers to a disk file and want to ensure
I don't pass the original buffer pointer over to zmq_send only to
have it corrupted (or bogus) by the time the sending is actually done
which could possibly cause a SEGV, a BUS error or just have bogus data
on the receiving end depending on what happened to the original buffer
provided earlier to zmq_send().

Hope that makes sense..

More information about the zeromq-dev mailing list