mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-13 02:42:58 +01:00
Prefer errno_assert/alloc_assert to zmq_assert
This commit is contained in:
parent
013967681d
commit
24b79c7e0b
@ -113,7 +113,7 @@ int zmq::ctx_t::terminate ()
|
|||||||
int rc = term_mailbox.recv (&cmd, -1);
|
int rc = term_mailbox.recv (&cmd, -1);
|
||||||
if (rc == -1 && errno == EINTR)
|
if (rc == -1 && errno == EINTR)
|
||||||
return -1;
|
return -1;
|
||||||
zmq_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
zmq_assert (cmd.type == command_t::done);
|
zmq_assert (cmd.type == command_t::done);
|
||||||
slot_sync.lock ();
|
slot_sync.lock ();
|
||||||
zmq_assert (sockets.empty ());
|
zmq_assert (sockets.empty ());
|
||||||
|
@ -89,7 +89,7 @@ bool zmq::dealer_t::xhas_in ()
|
|||||||
int rc = dealer_t::xrecv (&prefetched_msg, ZMQ_DONTWAIT);
|
int rc = dealer_t::xrecv (&prefetched_msg, ZMQ_DONTWAIT);
|
||||||
if (rc != 0 && errno == EAGAIN)
|
if (rc != 0 && errno == EAGAIN)
|
||||||
return false;
|
return false;
|
||||||
zmq_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
prefetched = true;
|
prefetched = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_)
|
|||||||
int rc = msg_->close ();
|
int rc = msg_->close ();
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
rc = msg_->init ();
|
rc = msg_->init ();
|
||||||
zmq_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ int zmq::lb_t::send (msg_t *msg_, int flags_)
|
|||||||
int rc = msg_->close ();
|
int rc = msg_->close ();
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
rc = msg_->init ();
|
rc = msg_->init ();
|
||||||
zmq_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
|
|||||||
count = (min < c ? c - min : min - c) + 1;
|
count = (min < c ? c - min : min - c) + 1;
|
||||||
next.table = (mtrie_t**)
|
next.table = (mtrie_t**)
|
||||||
malloc (sizeof (mtrie_t*) * count);
|
malloc (sizeof (mtrie_t*) * count);
|
||||||
zmq_assert (next.table);
|
alloc_assert (next.table);
|
||||||
for (unsigned short i = 0; i != count; ++i)
|
for (unsigned short i = 0; i != count; ++i)
|
||||||
next.table [i] = 0;
|
next.table [i] = 0;
|
||||||
min = std::min (min, c);
|
min = std::min (min, c);
|
||||||
@ -107,7 +107,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
|
|||||||
count = c - min + 1;
|
count = c - min + 1;
|
||||||
next.table = (mtrie_t**) realloc ((void*) next.table,
|
next.table = (mtrie_t**) realloc ((void*) next.table,
|
||||||
sizeof (mtrie_t*) * count);
|
sizeof (mtrie_t*) * count);
|
||||||
zmq_assert (next.table);
|
alloc_assert (next.table);
|
||||||
for (unsigned short i = old_count; i != count; i++)
|
for (unsigned short i = old_count; i != count; i++)
|
||||||
next.table [i] = NULL;
|
next.table [i] = NULL;
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
|
|||||||
count = (min + old_count) - c;
|
count = (min + old_count) - c;
|
||||||
next.table = (mtrie_t**) realloc ((void*) next.table,
|
next.table = (mtrie_t**) realloc ((void*) next.table,
|
||||||
sizeof (mtrie_t*) * count);
|
sizeof (mtrie_t*) * count);
|
||||||
zmq_assert (next.table);
|
alloc_assert (next.table);
|
||||||
memmove (next.table + min - c, next.table,
|
memmove (next.table + min - c, next.table,
|
||||||
old_count * sizeof (mtrie_t*));
|
old_count * sizeof (mtrie_t*));
|
||||||
for (unsigned short i = 0; i != min - c; i++)
|
for (unsigned short i = 0; i != min - c; i++)
|
||||||
@ -132,7 +132,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
|
|||||||
if (!next.node) {
|
if (!next.node) {
|
||||||
next.node = new (std::nothrow) mtrie_t;
|
next.node = new (std::nothrow) mtrie_t;
|
||||||
++live_nodes;
|
++live_nodes;
|
||||||
zmq_assert (next.node);
|
alloc_assert (next.node);
|
||||||
}
|
}
|
||||||
return next.node->add_helper (prefix_ + 1, size_ - 1, pipe_);
|
return next.node->add_helper (prefix_ + 1, size_ - 1, pipe_);
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
|
|||||||
if (!next.table [c - min]) {
|
if (!next.table [c - min]) {
|
||||||
next.table [c - min] = new (std::nothrow) mtrie_t;
|
next.table [c - min] = new (std::nothrow) mtrie_t;
|
||||||
++live_nodes;
|
++live_nodes;
|
||||||
zmq_assert (next.table [c - min]);
|
alloc_assert (next.table [c - min]);
|
||||||
}
|
}
|
||||||
return next.table [c - min]->add_helper (prefix_ + 1, size_ - 1, pipe_);
|
return next.table [c - min]->add_helper (prefix_ + 1, size_ - 1, pipe_);
|
||||||
}
|
}
|
||||||
@ -260,7 +260,7 @@ void zmq::mtrie_t::rm_helper (pipe_t *pipe_, unsigned char **buff_,
|
|||||||
|
|
||||||
count = new_max - new_min + 1;
|
count = new_max - new_min + 1;
|
||||||
next.table = (mtrie_t**) malloc (sizeof (mtrie_t*) * count);
|
next.table = (mtrie_t**) malloc (sizeof (mtrie_t*) * count);
|
||||||
zmq_assert (next.table);
|
alloc_assert (next.table);
|
||||||
|
|
||||||
memmove (next.table, old_table + (new_min - min),
|
memmove (next.table, old_table + (new_min - min),
|
||||||
sizeof (mtrie_t*) * count);
|
sizeof (mtrie_t*) * count);
|
||||||
@ -353,7 +353,7 @@ bool zmq::mtrie_t::rm_helper (unsigned char *prefix_, size_t size_,
|
|||||||
|
|
||||||
count = count - (new_min - min);
|
count = count - (new_min - min);
|
||||||
next.table = (mtrie_t**) malloc (sizeof (mtrie_t*) * count);
|
next.table = (mtrie_t**) malloc (sizeof (mtrie_t*) * count);
|
||||||
zmq_assert (next.table);
|
alloc_assert (next.table);
|
||||||
|
|
||||||
memmove (next.table, old_table + (new_min - min),
|
memmove (next.table, old_table + (new_min - min),
|
||||||
sizeof (mtrie_t*) * count);
|
sizeof (mtrie_t*) * count);
|
||||||
@ -375,7 +375,7 @@ bool zmq::mtrie_t::rm_helper (unsigned char *prefix_, size_t size_,
|
|||||||
|
|
||||||
mtrie_t **old_table = next.table;
|
mtrie_t **old_table = next.table;
|
||||||
next.table = (mtrie_t**) malloc (sizeof (mtrie_t*) * count);
|
next.table = (mtrie_t**) malloc (sizeof (mtrie_t*) * count);
|
||||||
zmq_assert (next.table);
|
alloc_assert (next.table);
|
||||||
|
|
||||||
memmove (next.table, old_table, sizeof (mtrie_t*) * count);
|
memmove (next.table, old_table, sizeof (mtrie_t*) * count);
|
||||||
free (old_table);
|
free (old_table);
|
||||||
|
@ -197,7 +197,7 @@ void zmq::pgm_sender_t::out_event ()
|
|||||||
add_timer (timeout, tx_timer_id);
|
add_timer (timeout, tx_timer_id);
|
||||||
has_tx_timer = true;
|
has_tx_timer = true;
|
||||||
} else
|
} else
|
||||||
zmq_assert (errno == EBUSY);
|
errno_assert (errno == EBUSY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,8 @@ int zmq::session_base_t::read (msg_t *msg_)
|
|||||||
// First message to send is identity (if required).
|
// First message to send is identity (if required).
|
||||||
if (send_identity) {
|
if (send_identity) {
|
||||||
zmq_assert (!(msg_->flags () & msg_t::more));
|
zmq_assert (!(msg_->flags () & msg_t::more));
|
||||||
msg_->init_size (options.identity_size);
|
int rc = msg_->init_size (options.identity_size);
|
||||||
|
errno_assert (rc == 0);
|
||||||
memcpy (msg_->data (), options.identity, options.identity_size);
|
memcpy (msg_->data (), options.identity, options.identity_size);
|
||||||
send_identity = false;
|
send_identity = false;
|
||||||
incomplete_in = false;
|
incomplete_in = false;
|
||||||
@ -449,7 +450,7 @@ void zmq::session_base_t::start_connecting (bool wait_)
|
|||||||
alloc_assert (pgm_sender);
|
alloc_assert (pgm_sender);
|
||||||
|
|
||||||
int rc = pgm_sender->init (udp_encapsulation, addr->address.c_str ());
|
int rc = pgm_sender->init (udp_encapsulation, addr->address.c_str ());
|
||||||
zmq_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
|
||||||
send_attach (this, pgm_sender);
|
send_attach (this, pgm_sender);
|
||||||
}
|
}
|
||||||
@ -461,7 +462,7 @@ void zmq::session_base_t::start_connecting (bool wait_)
|
|||||||
alloc_assert (pgm_receiver);
|
alloc_assert (pgm_receiver);
|
||||||
|
|
||||||
int rc = pgm_receiver->init (udp_encapsulation, addr->address.c_str ());
|
int rc = pgm_receiver->init (udp_encapsulation, addr->address.c_str ());
|
||||||
zmq_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
|
||||||
send_attach (this, pgm_receiver);
|
send_attach (this, pgm_receiver);
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ int zmq::signaler_t::wait (int timeout_)
|
|||||||
pfd.events = POLLIN;
|
pfd.events = POLLIN;
|
||||||
int rc = poll (&pfd, 1, timeout_);
|
int rc = poll (&pfd, 1, timeout_);
|
||||||
if (unlikely (rc < 0)) {
|
if (unlikely (rc < 0)) {
|
||||||
zmq_assert (errno == EINTR);
|
errno_assert (errno == EINTR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (unlikely (rc == 0)) {
|
else if (unlikely (rc == 0)) {
|
||||||
@ -173,7 +173,7 @@ int zmq::signaler_t::wait (int timeout_)
|
|||||||
int rc = select (r + 1, &fds, NULL, NULL,
|
int rc = select (r + 1, &fds, NULL, NULL,
|
||||||
timeout_ >= 0 ? &timeout : NULL);
|
timeout_ >= 0 ? &timeout : NULL);
|
||||||
if (unlikely (rc < 0)) {
|
if (unlikely (rc < 0)) {
|
||||||
zmq_assert (errno == EINTR);
|
errno_assert (errno == EINTR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -448,7 +448,7 @@ int zmq::socket_base_t::connect (const char *addr_)
|
|||||||
if (options.send_identity) {
|
if (options.send_identity) {
|
||||||
msg_t id;
|
msg_t id;
|
||||||
rc = id.init_size (options.identity_size);
|
rc = id.init_size (options.identity_size);
|
||||||
zmq_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
memcpy (id.data (), options.identity, options.identity_size);
|
memcpy (id.data (), options.identity, options.identity_size);
|
||||||
id.set_flags (msg_t::identity);
|
id.set_flags (msg_t::identity);
|
||||||
bool written = pipes [0]->write (&id);
|
bool written = pipes [0]->write (&id);
|
||||||
@ -460,7 +460,7 @@ int zmq::socket_base_t::connect (const char *addr_)
|
|||||||
if (peer.options.send_identity) {
|
if (peer.options.send_identity) {
|
||||||
msg_t id;
|
msg_t id;
|
||||||
rc = id.init_size (peer.options.identity_size);
|
rc = id.init_size (peer.options.identity_size);
|
||||||
zmq_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
memcpy (id.data (), peer.options.identity, peer.options.identity_size);
|
memcpy (id.data (), peer.options.identity, peer.options.identity_size);
|
||||||
id.set_flags (msg_t::identity);
|
id.set_flags (msg_t::identity);
|
||||||
bool written = pipes [1]->write (&id);
|
bool written = pipes [1]->write (&id);
|
||||||
@ -487,12 +487,12 @@ int zmq::socket_base_t::connect (const char *addr_)
|
|||||||
}
|
}
|
||||||
|
|
||||||
address_t *paddr = new (std::nothrow) address_t (protocol, address);
|
address_t *paddr = new (std::nothrow) address_t (protocol, address);
|
||||||
zmq_assert (paddr);
|
alloc_assert (paddr);
|
||||||
|
|
||||||
// Resolve address (if needed by the protocol)
|
// Resolve address (if needed by the protocol)
|
||||||
if (protocol == "tcp") {
|
if (protocol == "tcp") {
|
||||||
paddr->resolved.tcp_addr = new (std::nothrow) tcp_address_t ();
|
paddr->resolved.tcp_addr = new (std::nothrow) tcp_address_t ();
|
||||||
zmq_assert (paddr->resolved.tcp_addr);
|
alloc_assert (paddr->resolved.tcp_addr);
|
||||||
int rc = paddr->resolved.tcp_addr->resolve (
|
int rc = paddr->resolved.tcp_addr->resolve (
|
||||||
address.c_str (), false, options.ipv4only ? true : false);
|
address.c_str (), false, options.ipv4only ? true : false);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
@ -503,7 +503,7 @@ int zmq::socket_base_t::connect (const char *addr_)
|
|||||||
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
|
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
|
||||||
else if(protocol == "ipc") {
|
else if(protocol == "ipc") {
|
||||||
paddr->resolved.ipc_addr = new (std::nothrow) ipc_address_t ();
|
paddr->resolved.ipc_addr = new (std::nothrow) ipc_address_t ();
|
||||||
zmq_assert (paddr->resolved.ipc_addr);
|
alloc_assert (paddr->resolved.ipc_addr);
|
||||||
int rc = paddr->resolved.ipc_addr->resolve (address.c_str ());
|
int rc = paddr->resolved.ipc_addr->resolve (address.c_str ());
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
delete paddr;
|
delete paddr;
|
||||||
|
@ -59,14 +59,14 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
|
|||||||
|
|
||||||
// Create a socket.
|
// Create a socket.
|
||||||
int fd = open_socket (AF_INET, SOCK_DGRAM, 0);
|
int fd = open_socket (AF_INET, SOCK_DGRAM, 0);
|
||||||
zmq_assert (fd != -1);
|
errno_assert (fd != -1);
|
||||||
|
|
||||||
// Retrieve number of interfaces.
|
// Retrieve number of interfaces.
|
||||||
lifnum ifn;
|
lifnum ifn;
|
||||||
ifn.lifn_family = AF_INET;
|
ifn.lifn_family = AF_INET;
|
||||||
ifn.lifn_flags = 0;
|
ifn.lifn_flags = 0;
|
||||||
int rc = ioctl (fd, SIOCGLIFNUM, (char*) &ifn);
|
int rc = ioctl (fd, SIOCGLIFNUM, (char*) &ifn);
|
||||||
zmq_assert (rc != -1);
|
errno_assert (rc != -1);
|
||||||
|
|
||||||
// Allocate memory to get interface names.
|
// Allocate memory to get interface names.
|
||||||
size_t ifr_size = sizeof (struct lifreq) * ifn.lifn_count;
|
size_t ifr_size = sizeof (struct lifreq) * ifn.lifn_count;
|
||||||
@ -80,7 +80,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
|
|||||||
ifc.lifc_len = ifr_size;
|
ifc.lifc_len = ifr_size;
|
||||||
ifc.lifc_buf = ifr;
|
ifc.lifc_buf = ifr;
|
||||||
rc = ioctl (fd, SIOCGLIFCONF, (char*) &ifc);
|
rc = ioctl (fd, SIOCGLIFCONF, (char*) &ifc);
|
||||||
zmq_assert (rc != -1);
|
errno_assert (rc != -1);
|
||||||
|
|
||||||
// Find the interface with the specified name and AF_INET family.
|
// Find the interface with the specified name and AF_INET family.
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@ -89,7 +89,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
|
|||||||
n ++, ifrp ++) {
|
n ++, ifrp ++) {
|
||||||
if (!strcmp (nic_, ifrp->lifr_name)) {
|
if (!strcmp (nic_, ifrp->lifr_name)) {
|
||||||
rc = ioctl (fd, SIOCGLIFADDR, (char*) ifrp);
|
rc = ioctl (fd, SIOCGLIFADDR, (char*) ifrp);
|
||||||
zmq_assert (rc != -1);
|
errno_assert (rc != -1);
|
||||||
if (ifrp->lifr_addr.ss_family == AF_INET) {
|
if (ifrp->lifr_addr.ss_family == AF_INET) {
|
||||||
address.ipv4 = *(sockaddr_in*) &ifrp->lifr_addr;
|
address.ipv4 = *(sockaddr_in*) &ifrp->lifr_addr;
|
||||||
found = true;
|
found = true;
|
||||||
@ -124,7 +124,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
|
|||||||
|
|
||||||
// Create a socket.
|
// Create a socket.
|
||||||
int sd = open_socket (AF_INET, SOCK_DGRAM, 0);
|
int sd = open_socket (AF_INET, SOCK_DGRAM, 0);
|
||||||
zmq_assert (sd != -1);
|
errno_assert (sd != -1);
|
||||||
|
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
|
|||||||
// Get the addresses.
|
// Get the addresses.
|
||||||
ifaddrs* ifa = NULL;
|
ifaddrs* ifa = NULL;
|
||||||
int rc = getifaddrs (&ifa);
|
int rc = getifaddrs (&ifa);
|
||||||
zmq_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
zmq_assert (ifa != NULL);
|
zmq_assert (ifa != NULL);
|
||||||
|
|
||||||
// Find the corresponding network interface.
|
// Find the corresponding network interface.
|
||||||
|
10
src/trie.cpp
10
src/trie.cpp
@ -80,7 +80,7 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
|
|||||||
count = (min < c ? c - min : min - c) + 1;
|
count = (min < c ? c - min : min - c) + 1;
|
||||||
next.table = (trie_t**)
|
next.table = (trie_t**)
|
||||||
malloc (sizeof (trie_t*) * count);
|
malloc (sizeof (trie_t*) * count);
|
||||||
zmq_assert (next.table);
|
alloc_assert (next.table);
|
||||||
for (unsigned short i = 0; i != count; ++i)
|
for (unsigned short i = 0; i != count; ++i)
|
||||||
next.table [i] = 0;
|
next.table [i] = 0;
|
||||||
min = std::min (min, c);
|
min = std::min (min, c);
|
||||||
@ -117,7 +117,7 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
|
|||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
if (!next.node) {
|
if (!next.node) {
|
||||||
next.node = new (std::nothrow) trie_t;
|
next.node = new (std::nothrow) trie_t;
|
||||||
zmq_assert (next.node);
|
alloc_assert (next.node);
|
||||||
++live_nodes;
|
++live_nodes;
|
||||||
zmq_assert (live_nodes == 1);
|
zmq_assert (live_nodes == 1);
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
|
|||||||
else {
|
else {
|
||||||
if (!next.table [c - min]) {
|
if (!next.table [c - min]) {
|
||||||
next.table [c - min] = new (std::nothrow) trie_t;
|
next.table [c - min] = new (std::nothrow) trie_t;
|
||||||
zmq_assert (next.table [c - min]);
|
alloc_assert (next.table [c - min]);
|
||||||
++live_nodes;
|
++live_nodes;
|
||||||
zmq_assert (live_nodes > 1);
|
zmq_assert (live_nodes > 1);
|
||||||
}
|
}
|
||||||
@ -218,7 +218,7 @@ bool zmq::trie_t::rm (unsigned char *prefix_, size_t size_)
|
|||||||
|
|
||||||
count = count - (new_min - min);
|
count = count - (new_min - min);
|
||||||
next.table = (trie_t**) malloc (sizeof (trie_t*) * count);
|
next.table = (trie_t**) malloc (sizeof (trie_t*) * count);
|
||||||
zmq_assert (next.table);
|
alloc_assert (next.table);
|
||||||
|
|
||||||
memmove (next.table, old_table + (new_min - min),
|
memmove (next.table, old_table + (new_min - min),
|
||||||
sizeof (trie_t*) * count);
|
sizeof (trie_t*) * count);
|
||||||
@ -242,7 +242,7 @@ bool zmq::trie_t::rm (unsigned char *prefix_, size_t size_)
|
|||||||
|
|
||||||
trie_t **old_table = next.table;
|
trie_t **old_table = next.table;
|
||||||
next.table = (trie_t**) malloc (sizeof (trie_t*) * count);
|
next.table = (trie_t**) malloc (sizeof (trie_t*) * count);
|
||||||
zmq_assert (next.table);
|
alloc_assert (next.table);
|
||||||
|
|
||||||
memmove (next.table, old_table, sizeof (trie_t*) * count);
|
memmove (next.table, old_table, sizeof (trie_t*) * count);
|
||||||
free (old_table);
|
free (old_table);
|
||||||
|
@ -150,7 +150,7 @@ int zmq::xsub_t::xrecv (msg_t *msg_, int flags_)
|
|||||||
// from the pipe.
|
// from the pipe.
|
||||||
while (msg_->flags () & msg_t::more) {
|
while (msg_->flags () & msg_t::more) {
|
||||||
rc = fq.recv (msg_);
|
rc = fq.recv (msg_);
|
||||||
zmq_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ bool zmq::xsub_t::xhas_in ()
|
|||||||
// If there's no message available, return immediately.
|
// If there's no message available, return immediately.
|
||||||
// The same when error occurs.
|
// The same when error occurs.
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
zmq_assert (errno == EAGAIN);
|
errno_assert (errno == EAGAIN);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ bool zmq::xsub_t::xhas_in ()
|
|||||||
// from the pipe.
|
// from the pipe.
|
||||||
while (message.flags () & msg_t::more) {
|
while (message.flags () & msg_t::more) {
|
||||||
rc = fq.recv (&message);
|
rc = fq.recv (&message);
|
||||||
zmq_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ void zmq::xsub_t::send_subscription (unsigned char *data_, size_t size_,
|
|||||||
// Create the subsctription message.
|
// Create the subsctription message.
|
||||||
msg_t msg;
|
msg_t msg;
|
||||||
int rc = msg.init_size (size_ + 1);
|
int rc = msg.init_size (size_ + 1);
|
||||||
zmq_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
unsigned char *data = (unsigned char*) msg.data ();
|
unsigned char *data = (unsigned char*) msg.data ();
|
||||||
data [0] = 1;
|
data [0] = 1;
|
||||||
memcpy (data + 1, data_, size_);
|
memcpy (data + 1, data_, size_);
|
||||||
|
Loading…
Reference in New Issue
Block a user