[zeromq-dev] Message initialisation

KIU Shueng Chuan nixchuan at gmail.com
Fri May 2 00:50:57 CEST 2014


> zmq_msg_close() does not return with an error code when applied to an
> "empty" zmq_msg_t, neither one that has just been sent nor one that has
> been initialised as empty.  However, if I call it *again* on the same
> message, it fails:
>
>      zmq_msg_t m;
>      zmq_msg_init(&m);
>      assert(zmq_msg_close(&m) == 0); // Passes
>      assert(zmq_msg_close(&m) == 0); // Fails
>
> In other words, closing an empty message is apparently not a no-op.  So,
> what is the difference between an empty message and a closed message?

A closed message is the same as an uninitialized zmq_msg_t. It becomes just
a blob of memory.

Implementation-wise, close scrubs away some magic id that identifies it as
being initialized or not. That's why the second close fails.

It would be simpler just to ignore the part about send nullifying the
message on success. Just pair every init with a close.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140502/17965814/attachment.htm>


More information about the zeromq-dev mailing list