Changeset View
Changeset View
Standalone View
Standalone View
src/zmq/zmqpublishnotifier.cpp
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | void CZMQAbstractPublishNotifier::Shutdown() { | ||||
if (count == 1) { | if (count == 1) { | ||||
LogPrint(BCLog::ZMQ, "Close socket at address %s\n", address); | LogPrint(BCLog::ZMQ, "Close socket at address %s\n", address); | ||||
int linger = 0; | int linger = 0; | ||||
zmq_setsockopt(psocket, ZMQ_LINGER, &linger, sizeof(linger)); | zmq_setsockopt(psocket, ZMQ_LINGER, &linger, sizeof(linger)); | ||||
zmq_close(psocket); | zmq_close(psocket); | ||||
} | } | ||||
psocket = 0; | psocket = nullptr; | ||||
} | } | ||||
bool CZMQAbstractPublishNotifier::SendMessage(const char *command, | bool CZMQAbstractPublishNotifier::SendMessage(const char *command, | ||||
const void *data, size_t size) { | const void *data, size_t size) { | ||||
assert(psocket); | assert(psocket); | ||||
/* send three parts, command & data & a LE 4byte sequence number */ | /* send three parts, command & data & a LE 4byte sequence number */ | ||||
uint8_t msgseq[sizeof(uint32_t)]; | uint8_t msgseq[sizeof(uint32_t)]; | ||||
WriteLE32(&msgseq[0], nSequence); | WriteLE32(&msgseq[0], nSequence); | ||||
int rc = zmq_send_multipart(psocket, command, strlen(command), data, size, | int rc = zmq_send_multipart(psocket, command, strlen(command), data, size, | ||||
msgseq, (size_t)sizeof(uint32_t), (void *)0); | msgseq, (size_t)sizeof(uint32_t), nullptr); | ||||
if (rc == -1) { | if (rc == -1) { | ||||
return false; | return false; | ||||
} | } | ||||
/* increment memory only sequence number after sending */ | /* increment memory only sequence number after sending */ | ||||
nSequence++; | nSequence++; | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |