[nanomsg] Re: why memcpy data to be sent?

  • From: Martin Sustrik <sustrik@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Thu, 30 Oct 2014 07:05:26 +0100

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

On 29/10/14 21:27, Steve Vinoski wrote:

> Perhaps I'll give it a try if I can find some cycles.

Ok, if you do, here are some thought on the topic:

1. The functionality should be disabled on Windows. IOCP overlapped
send takes a buffer and either sends it immediately or delays the
completion. Which in turn means we have no way to copy the buffer
*after* the send fails and re-try the send.

2. Each message can be sent to multiple destinations:

    p = nn_socket (AF_SP, NN_PUB);
    nn_connect (p, "tcp://192.168.0.100:5555");
    nn_connect (p, "ipc://test.ipc");
    nn_connect (p, "inproc://test");
    nn_send (p, "ABC", 3, 0);

Some of them may succeed sending the message straight away, some may
not. Thus, the reasonable thing to do would be to try to send the
original un-copied buffer to each of them in turn and make the copy of
it only after the first failure.

3. Avoiding the copy on the rx side of things is probably not possible
(short of using nn_allocmsg() mechanism) because messages can be
received from multiple destinations and can be read from the network
in parallel. So, at the time of nn_recv() call it cannot be predicted
which connection will recv a full message first and thus we have no
idea which connection to assign the user buffer to.

Martin


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJUUdUmAAoJENTpVjxCNN9Yio4H/RuNjrgtjETRXWEP3c3ubTZr
snkMU+R/LatTB2ZgbIqnZvf8QfkwwkrmRMR3D3feyAgKu6SCFoBR91PVX6oXpZq5
TsFy/zErqb2K8lSwu3fch/fkDuMS2lqsOf150/35ITzq+tZ0AyMqYH4ERgHnXl2G
W3QFmZ6PmyAli84PRTyyFW8LrbEgiBEWnm9bIfsotJ6Mumoh4nb+zjO+qxZ3K+A3
mS0CmnWEiafHIm8fRIvsYmO2v3eqNsObx/pblOm8Ta7tvYqyezy9Yh3LTb2CpFv2
QvlLxDmdAp1mF9/gSUjOc/DhAjzLzRVRQxsg+WlMhWbCHAwSbu6MjZyAQshcVL4=
=39Do
-----END PGP SIGNATURE-----

Other related posts: