[zeromq-dev] [2.1.0] Problems with lruqueue from The Guide (tm)

Steven McCoy steven.mccoy at miru.hk
Wed Dec 8 06:04:01 CET 2010


Raised on IRC, this example doesn't appear to work as expected.  On Ubuntu
10.10 it aborts,

Worker: HELLO
Worker: HELLO
Worker: HELLO
Client: OK
Worker: HELLO
Client: OK
Worker: HELLO
Client: OK
Worker: HELLO
Client: OK
Worker: HELLO
Client: OK
Worker: HELLO
Client: OK
Worker: HELLO
Client: OK
Worker: HELLO
Client: OK
Client: OK
Client: OK
lruqueue: zhelpers.h:45: s_recv: Assertion `zmq_recv (socket, &message, 0)
== 0' failed.
Aborted

Split the code into two programs, one multi-client, one server, then the
client hangs in zmq_term unless you modify the code to close each 0MQ socket
before closing the thread, i.e.

--- lruqueue.c  2010-12-08 12:39:08.000000000 +0800
+++ client.c    2010-12-08 12:59:14.000000000 +0800
@@ -17,6 +17,8 @@
     char *reply = s_recv (client);
     printf ("Client: %s\n", reply);
     free (reply);
+
+    zmq_close (client);
     return (NULL);
 }

Remove setting ZMQ_IDENTITY, i.e. defaulting to UUID, then the client never
sees a reply from the server,

--- lruqueue.c  2010-12-08 12:39:08.000000000 +0800
+++ client.c    2010-12-08 12:59:34.000000000 +0800
@@ -9,7 +9,7 @@
 static void *
 client_thread (void *context) {
     void *client = zmq_socket (context, ZMQ_REQ);
-    s_set_id (client);          //  Makes tracing easier
+//    s_set_id (client);          //  Makes tracing easier
     zmq_connect (client, "ipc://frontend");

     //  Send request, get reply

*client:*
client: zhelpers.h:45: s_recv: Assertion `zmq_recv (socket, &message, 0) ==
0' failed.
Aborted

*server:*
Worker: HELLO
Worker: HELLO
Worker: HELLO
Worker: HELLO
Worker: HELLO
Worker: HELLO
Worker: HELLO
Worker: HELLO
Worker: HELLO
Worker: HELLO

-- 
Steve-o
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20101208/01df8b4f/attachment.htm>


More information about the zeromq-dev mailing list