使用ZeroMQ 4.0.5,我有一些代码作为代理,从一个套接字读取并写入另一个套接字。发送的目标套接字是TCP DEALER。在特定的复杂测试用例中,zmq_msg_send错误并将errno设置为EAGAIN。
当我阅读文档时,这不应该是可能的; EAGAIN应该需要ZMQ_DONTWAIT标志或超时。我没有传递ZMQ_DONTWAIT,我没有调用zmq_setsockopt来设置超时。我错过了什么?
我添加了一个套接字监视器,证据表明,当发生这种情况时,另一端没有人接收。所以,根据文档,我希望阻止,因为我没有通过ZMQ_DONTWAIT并且我没有设置超时。
int len = zmq_msg_recv(&msg, fromSocket, 0);
if (len == -1) {
int err = errno;
if (err != ETERM) {
fail("ZmqTransportMultiplexer::pass %s %s from zmq_msg_recv\n", trace,
zmq_strerror(err));
// no need to log ordinary closure.
}
throw ZmqMultiplexerShutdown();
}
/* Preserve the part structure. The code in ZmqTransport.cpp would
* work just the same if this converted to multiple messages and
* did not preserve the multi-part structure, but this code
* accounts for the possibility that we change our mind.
*/
int more = zmq_msg_more(&msg);
len = zmq_msg_send(&msg, toSocket, more != 0 ? ZMQ_SNDMORE : 0);
if (len == -1) {
int err = errno;
if (err != ETERM) {
fail("ZmqTransportMultiplexer::pass %s %s from zmq_msg_send length %d\n",
trace,
zmq_strerror(err),
zmq_msg_size(&msg));
}
throw ZmqMultiplexerShutdown();
}