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

Rick Flower nrf at ca-flower.com
Tue Jan 24 19:22:52 CET 2012


hi all.. I've got a question regarding the zero-copy stuff.. I've 
currently
got a handful of threads that have messages that are not allocated 
per-se (or
may be taken from an STL vector behind the scenes).  These messages are 
to
be logged by a logging thread.  Currently the code (which does work by 
the way),
takes these messages to be logged (which are rather large), allocates a 
packet
buffer with some housekeeping info and copies the passed-in data into 
the
allocated packet area prior to calling zmqsend to the logging thread.  
I ran
across, again, the paragraph in the guide talking about zero-copy and 
want to
know if I omit the malloc/memcpy stuff if I'm going to get into trouble 
since
the buffer may not be actually send (but would be queued) prior to the 
message
buffer disappearing for whatever reason AFTER the zmq send returned and 
further
processing performed by the thread that just finished logging that 
message..
Does that seem reasonable?  I just want to make sure I'm not 
allocating/copying
if I don't have to.. Thanks!




More information about the zeromq-dev mailing list