Search code examples
czeromq

zmq_send() blocks on recv()/poll()


I try to send a few small (8 byte) messages through inproc pair socket. However after a few tries zmq_send() blocks. When I stop debugger I see following stack trace:

libc.so.6!__GI___poll(struct pollfd * fds, nfds_t nfds, int timeout) 
libzmq.so.5!poll(int __timeout, nfds_t __nfds, pollfd * __fds) 
libzmq.so.5!zmq::signaler_t::wait(zmq::signaler_t * const this, int timeout_) 
libzmq.so.5!zmq::mailbox_t::recv(zmq::mailbox_t * const this, zmq::command_t * cmd_, int timeout_) 
libzmq.so.5!zmq::socket_base_t::process_commands(zmq::socket_base_t * const this, int timeout_, bool throttle_) 
libzmq.so.5!zmq::socket_base_t::send(zmq::socket_base_t * const this, zmq::msg_t * msg_, int flags_) 
libzmq.so.5!s_sendmsg(int flags_, zmq_msg_t * msg_, zmq::socket_base_t * s_) 
libzmq.so.5!zmq_send(void * s_, const void * buf_, size_t len_, int flags_)

Why does it happen? What commands does ZMQ try to to process? Why does it call recv()? Is it because of high water mark? I suppose it's something different because I send small amount of data and water mark shouldn't be reached yet. And if water mark is the only explanation then how can I measure it?


Solution

  • It turned out it was bug in logic of my code. After sending some messages, next were sent by different thread using different socket. That socket was not connected so zmq_send() was waiting for connection to be established. This is why its pipe was NULL. Thanks everybody for help.