I'm working on a Majordomo implementation in Perl using the ZeroMQ-0.21 wrapper 
and have a mystery concerning AnyEvent support with it.

I'm using AE to drive the broker (using AE I/O watchers for incoming traffic on 
the worker and client sockets, and setting up AE timers to handle heartbeats 
and worker expiration) and it is working great.

However, in my client, if I set up AnyEvent to wait for the reply from the 
broker I am never notified. The client works perfectly if I use a synchronous 
receive on the socket.

The client script is here: http://pastebin.com/mzb4m47x

strace output for synchronous (working) is here: http://pastebin.com/Cz3dPx26
strace output for async (broken) is here: http://pastebin.com/Vhy5XN19

The interesting thing in the trace is the action taken when the message is 
received by the I/O thread. In the sync case:

5544  recvfrom(17, "\7\1MDPC02\2\1\4\t\1test_svc\2\0011\t\0OK 27609", 8192, 0, 
NULL, NULL) = 34
5544  sendto(14, "\0", 1, 0, NULL, 0)   = 1
5542  <... poll resumed> )              = 1 ([{fd=15, revents=POLLIN}])
5544  epoll_wait(11,  <unfinished ...>
5542  recvfrom(15, "\0", 1, 0, NULL, NULL) = 1
5542  poll([{fd=15, events=POLLIN}], 1, 0) = 0 (Timeout)
5542  write(1, "Rcv: MDPC02\n", 12)     = 12
5542  write(1, "Rcv: 0x04\n", 10)       = 10
5542  write(1, "Rcv: test_svc\n", 14)   = 14
5542  write(1, "Rcv: 1\n", 7)           = 7
5542  write(1, "Rcv: OK 27609\n", 14)   = 14

We receive the message on fd 17 with the response (the OK message), and send a 
byte down the notification pipe which wakes up the main thread (5542) and it 
writes the output. However, in the async case:

6496  recvfrom(17, "\7\1MDPC02\2\1\4\t\1test_svc\2\0011\t\0OK 27609", 8192, 0, 
NULL, NULL) = 34
6496  epoll_wait(11,  <unfinished ...>
6494  <... epoll_wait resumed> 201fdce0, 64, 59743) = -1 EINTR (Interrupted 
system call)
6494  --- SIGINT (Interrupt) @ 0 (0) ---

the I/O thread receives the message, and goes back to waiting, not sending a 
notification. 

It seems like I must be missing some setup here, but the structure of the 
broker messaging is much the same. There I have a ZeroMQ::Poller in place, but 
the behavior here does not change if I create the poller object (I never get 
the AnyEvent notification so the poller never would have been invoked anyway).

Thanks for any pointers,
--bob
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to