rsRetVal outputCZMQ(uchar* msg, instanceData* pData) { DEFiRet; /* if auth or socket is missing, initialize */ if((NULL == pData->sock) || (NULL == pData->authActor)) { CHKiRet(initCZMQ(pData)); } /* if we have a ZMQ_PUB sock and topics, send once per topic */ if (pData->sockType == ZMQ_PUB && pData->topics) { char *topic = zlist_first(pData->topics); while (topic) { if (pData->topicFrame) { int rc = zstr_sendx(pData->sock, topic, (char*)msg, NULL); if (rc != 0) { pData->sendError = true; ABORT_FINALIZE(RS_RET_SUSPENDED); } } else { int rc = zstr_sendf(pData->sock, "%s%s", topic, (char*)msg); if (rc != 0) { pData->sendError = true; ABORT_FINALIZE(RS_RET_SUSPENDED); } } topic = zlist_next(pData->topics); } } /* otherwise do a normal send */ else { int rc = zstr_send(pData->sock, (char*)msg); if (rc != 0) { pData->sendError = true; ABORT_FINALIZE(RS_RET_SUSPENDED); } } finalize_it: RETiRet; }
rsRetVal outputCZMQ(uchar* msg, instanceData* pData) { DEFiRet; /* if auth or socket is missing, initialize */ if((NULL == pData->sock) || (NULL == pData->authActor)) { CHKiRet(initCZMQ(pData)); } /* send the log line */ int rc = zstr_send(pData->sock, (char*)msg); /* something is very wrong */ if (rc == -1) { errmsg.LogError(0, NO_ERRCODE, "omczmq: send of %s failed: %s", msg, zmq_strerror(errno)); ABORT_FINALIZE(RS_RET_ERR); } finalize_it: RETiRet; }