[nanomsg] Weird problem with pipelines

  • From: Amaury Bouchard <amaury@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Mon, 26 Aug 2013 18:38:18 +0200

Hi all,

I have a very strange error in my project since I updated to the alpha
version.

I have threads (call them "A") which have to communicate with other threads
("B" and "C"). At the beginning, they were doing that using two nanomsg
streams: a fan-out (B thread PUSHing to A threads) and a fan-in (A threads
as SOURCE and C thread as SINK).

It worked perfectly. Now I changed all that to pipelines (SOURCE became
PUSH and SINK became PULL). And I got an error when an A thread try to read
in its PULL socket.

The error: "Assertion failed: !self->outpipe (.../src/utils/excl.c:71)"

It's weird because:
- If there is just one A thread, there is no error.
- If the thread doesn't open it's PUSH socket, there is no error.


Here is the code of the A threads:
<<<<

// open the stream from A threads to C thread
// if I comment this block, there is no error
if ((write_sock = nn_socket(AF_SP, NN_PUSH)) < 0 ||
    nn_connect(thread->write_sock, "inproc://writer_socket") < 0) {
        // exit gracefully
}
// open the stream from B thread to A threads
if ((incoming_socket = nn_socket(AF_SP, NN_PULL)) < 0 ||
    nn_connect(incoming_socket, ENDPOINT_THREADS_SOCKET) < 0) {
        // exit gracefully
}
for (; ; ) {
    // read what B sent to this thread
    // this instruction will generate the error
    if (nn_recv(incoming_socket, &thread->fd, sizeof(int), 0) < 0)
        continue;
    // do some stuff
}

>>>>


According to the excl.h file, the structure nn_excl should be used only for
PAIR connections...

Any idea?


Amaury

Other related posts: