[nanomsg] Re: towards a more robust socket model

  • From: Martin Sustrik <sustrik@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Sun, 16 Nov 2014 17:01:48 +0100

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

On 16/11/14 08:51, Drew Crawford wrote:

> * There has been months of discussion and a failed patch regarding 
> #324 <https://github.com/nanomsg/nanomsg/issues/324>

I've added a test to inproc.c which looks like this:

    /* Check whether SP message header is transferred correctly. */
    sb = test_socket (AF_SP_RAW, NN_REP);
    test_bind (sb, SOCKET_ADDRESS);
    sc = test_socket (AF_SP, NN_REQ);
    test_connect (sc, SOCKET_ADDRESS);

    test_send (sc, "ABC");

    iovec.iov_base = body;
    iovec.iov_len = sizeof (body);
    hdr.msg_iov = &iovec;
    hdr.msg_iovlen = 1;
    hdr.msg_control = &control;
    hdr.msg_controllen = NN_MSG;
    rc = nn_recvmsg (sb, &hdr, 0);
    errno_assert (rc == 3);

    cmsg = NN_CMSG_FIRSTHDR (&hdr);
    while (1) {
        nn_assert (cmsg);
        if (cmsg->cmsg_level == PROTO_SP && cmsg->cmsg_type == SP_HDR)
            break;
        cmsg = NN_CMSG_NXTHDR (&hdr, cmsg);
    }
    nn_assert (cmsg->cmsg_len == 8);
    data = NN_CMSG_DATA (cmsg);
    nn_assert (!(data[0] & 0x80));
    nn_assert (data[4] & 0x80);

    nn_freemsg (control);

    test_close (sc);
    test_close (sb);

And it seems to work OK. Can you check whether the problem persists?
And if so, can you make a test program to reproduce?

Martin

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

iQEcBAEBAgAGBQJUaMprAAoJENTpVjxCNN9YFncH/3WN+rPP2ZHlaausP9hH+Y/r
9Abdjoc3CITWXQ5Tr7suLnI0+vS1ZCBuIfqfvpQQ3Btvb2haDEcVg2HiwDoB7yKt
6io+CTmu4tk3SGeR6iFTAbHRyCopfbIbvJArirDJG4Wsu7gqXgU2QWpGS8BkDcPV
zb5AioMNfblj2SFZYzNDQMT2fyUWmCHlvBN7Ob7AgJkShE8cJcuPUxhWwtiyaFHG
kcIcwSVdkZfTxu4Acp/STtMWoZrWqlcPbpRbfunBjfQnj6/YruZcP7tDV1qipnoz
R2Y9xq9+tOhX2+Klb1R+BgdgAnwGoSfuqgHhv5MJmQZ7/WAcmDAcrwyd4rKeM/M=
=ls07
-----END PGP SIGNATURE-----

Other related posts: