[nanomsg] Re: do you use the cmsg API?

  • From: Michael Powell <mwpowellhtx@xxxxxxxxx>
  • To: "nanomsg@xxxxxxxxxxxxx" <nanomsg@xxxxxxxxxxxxx>
  • Date: Mon, 16 Nov 2015 15:57:30 -0500

On Mon, Nov 16, 2015 at 3:14 PM, Garrett D'Amore <garrett@xxxxxxxxxx> wrote:

I’ve found what I believe is a serious problem with the way the cmsg API is
used within libnanomsg. Basically, the SP headers that are stored there do
not include a correct length, only a “stored” length, which includes padding
for alignment.

Unfortunately, this breaks some things that use them, like the nn_device()
API.

(Btw, it was *not* easy to track this down.)

I think I’m going to need to change the cmsg implementation somewhat — in
particular in order for this to work I need to add a length field. This can
be added to the cmsg header structure, or I can embed it in the payload for
the SP header.

To be honest, I don’t have a strong opinion about which way to go.

In my experience with messaging frameworks, it usually works out
better if the payload can be ignorant of whatever packaging, including
message lengths. That's my two cents.

Here are the pros & cons:

* Changing the payload to inject a size ahead of the payload won’t affect
anything other than the SP_HDR portion.
* However changing the payload WILL break any code that currently relies on
the contents of the SP_HDR.

If you use the CMSG API with nanomsg, please take a moment to let me know
your thoughts. I’m interested to know how you’re using it (what CMSG
options are using it for), and if you have an opinion about either way.

I need to make a decision on this asap. This is now a blocker for 0.8.

- Garrett


Other related posts: