[nanomsg] Re: Richer API for manipulating zero-copy messages

  • From: Martin Sustrik <sustrik@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Tue, 13 May 2014 07:12:25 +0200

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Achille,

> - add a nn_reallocmsg call that would change the message size to
> fit just what we need, but may leave the memory buffer untouched,
> simply modifying its size in the metadata.

This sound like a viable option given that we already have nn_allocmsg
and nn_freemsg. However, the problem is that messages may be shared.
I.e. if you send a 1MB message to multiple inproc peers, each gets a
pointer to the same buffer, rather then their own copy. So, if one
peer reallocates the buffer, and realloc happens to move the position
of the buffer in the memory, all the remaining peers will end up with
invalid pointers.

Martin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTcam5AAoJENTpVjxCNN9YyNUIAIdfkHE4B5BDg3Iv5CafWBC/
ZSPcHChTsGa8Jmy2x0RcvGndJnLKC5iydWTzMfD1eHfSyfCTA7c19O1X1SvgKkMf
Ks1obFzXz5pE6Dv/+lLiYyILeuV5NSussgTMGrmIgC+/qik3QcLu7uEfOoOyNyeB
vf+ieAQOzyMW2PEa7pVhqpQts/Jhf95BZ5xc98Bdy6wxw+geSzKB6MTxBzZqmRDc
xtPT09FUB0KBswlEQbEaMJsFrzZrlsxxJrdo52rQJ60Q6GLrm5/TNB3zbHydVyIs
Hw+Rn3yzpewGNMqD5pDbLPoVnP2pH0bgs7LVKE8CHOHTLp5Bjo3BAx4YfUnhoYk=
=Iv6X
-----END PGP SIGNATURE-----

Other related posts: