Thank you Justin, I didn't check ZMQ_EVENTS afrer zmq_send and that is the problem! I check the ZMQ_EVENTS value after zmq_msg_send() called then I found the missing ZMQ_POLLIN event.
Now I have a simple workaround that feed (ev_feed_event) an additional event (EV_READ) to the watcher, the watcher handler will be invoked at next event loop iteration. Also review the zmq_getsockopt(3), option ZMQ_FD: = Note = The returned file descriptor is also used internally by the zmq_send and zmq_recv functions. As the descriptor is edge triggered, applications must update the state of ZMQ_EVENTS after each invocation of "zmq_send" or "zmq_recv". To be more explicit: after calling zmq_send the socket may become readable (and vice versa) without triggering a read event on the file descriptor. Thank you all. Best Regards, Cheyi Lin On Tue, Dec 11, 2012 at 1:37 AM, Justin Karneges <[email protected]> wrote: > I'm not sure if this is the issue you're having, but be aware that you have to > check ZMQ_EVENTS in *three* scenarios: after zmq_send, after zmq_recv, and > when ZMQ_FD triggers a read event. > > On Monday, December 10, 2012 04:39:22 PM CheYi Lin wrote: >> I'm using the low level API "zmq.h" in C, integrating zmq with libev >> event-loop. My program is complicated but the zmq & libev integration part >> is >> simple. (http://pastebin.com/6JiSh46N) >> >> Sorry I'm new to the community. >> Best Regards, >> Cheyi Lin >> >> On Mon, Dec 10, 2012 at 4:13 PM, Pieter Hintjens <[email protected]> wrote: >> > Can you make a raw test case (ideally in c using the low level API or >> > czmq)?> >> > On Dec 10, 2012 8:37 AM, "CheYi Lin" <[email protected]> wrote: >> >> Hi, >> >> >> >> I'm doing some zmq ROUTER-to-ROUTER experiments in my distributed >> >> system prototype. >> >> (single threaded, libev event loop based application) >> >> >> >> Below is my test steps: >> >> >> >> 1. ROUTER A and B start, set unique identity, bind the address. >> >> >> >> (handshake) >> >> 2. A connect to B. >> >> 3. A send HELLO to B continuously. >> >> 4. B recv HELLO then send HELLO_ACK back to A. >> >> 5. A recv HELLO_ACK and stop sending HELLO, handshake finished. >> >> >> >> (start communication) >> >> 6. A and B send HEARTBEAT to each other every 0.5 seconds. >> >> 7. When HEARTBEAT received, A and B print "recv HEARTBEAT". >> >> >> >> After about 30 seconds, A stop printing "recv HEARTBEAT" but B >> >> continue printing "recv HEARTBEAT". >> >> And few seconds later I terminate B, suddenly A print lots of "recv >> >> HEARTBEAT". >> >> >> >> I notice that A stop being signaled from the ZMQ_FD (in gdb), so all >> >> HEARTBEAT from B was queued >> >> after A stop printing "recv HEARTBEAT". >> >> >> >> My zmq-event handler: >> >> http://pastebin.com/6JiSh46N >> >> >> >> Don't know why the handler stop receiving ZMQ_EVENTS events. >> >> Could someone please review my code and give me some suggestions? >> >> >> >> Sorry for my bad english. >> >> >> >> >> >> Regards, >> >> Cheyi >> >> _______________________________________________ >> >> zeromq-dev mailing list >> >> [email protected] >> >> http://lists.zeromq.org/mailman/listinfo/zeromq-dev >> > >> > _______________________________________________ >> > zeromq-dev mailing list >> > [email protected] >> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev >> >> _______________________________________________ >> zeromq-dev mailing list >> [email protected] >> http://lists.zeromq.org/mailman/listinfo/zeromq-dev > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
