mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-20 22:31:33 +02:00
Problem: identifiers not conformant with naming convention
Solution: fix identifier names
This commit is contained in:

committed by
Simon Giesecke

parent
18edd28955
commit
a83c57d0bb
@@ -385,11 +385,11 @@ int zmq::ctx_t::get (int option_, void *optval_, size_t *optvallen_)
|
|||||||
|
|
||||||
int zmq::ctx_t::get (int option_)
|
int zmq::ctx_t::get (int option_)
|
||||||
{
|
{
|
||||||
int optval_ = 0;
|
int optval = 0;
|
||||||
size_t optvallen_ = sizeof (int);
|
size_t optvallen = sizeof (int);
|
||||||
|
|
||||||
if (get (option_, &optval_, &optvallen_) == 0)
|
if (get (option_, &optval, &optvallen) == 0)
|
||||||
return optval_;
|
return optval;
|
||||||
|
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
|
@@ -540,7 +540,7 @@ bool zmq::radix_tree_t::check (const unsigned char *key_, size_t key_size_)
|
|||||||
static void
|
static void
|
||||||
visit_keys (node_t node_,
|
visit_keys (node_t node_,
|
||||||
std::vector<unsigned char> &buffer_,
|
std::vector<unsigned char> &buffer_,
|
||||||
void (*func_) (unsigned char *data, size_t size, void *arg),
|
void (*func_) (unsigned char *data_, size_t size_, void *arg_),
|
||||||
void *arg_)
|
void *arg_)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < node_.prefix_length (); ++i)
|
for (size_t i = 0; i < node_.prefix_length (); ++i)
|
||||||
@@ -558,7 +558,7 @@ visit_keys (node_t node_,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void zmq::radix_tree_t::apply (
|
void zmq::radix_tree_t::apply (
|
||||||
void (*func_) (unsigned char *data, size_t size, void *arg), void *arg_)
|
void (*func_) (unsigned char *data_, size_t size_, void *arg_), void *arg_)
|
||||||
{
|
{
|
||||||
if (_root.refcount () > 0)
|
if (_root.refcount () > 0)
|
||||||
func_ (NULL, 0, arg_); // Root node is always empty.
|
func_ (NULL, 0, arg_); // Root node is always empty.
|
||||||
|
@@ -79,12 +79,12 @@ void zmq::socks_connecter_t::set_auth_method_none ()
|
|||||||
_auth_password.clear ();
|
_auth_password.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::socks_connecter_t::set_auth_method_basic (const std::string username,
|
void zmq::socks_connecter_t::set_auth_method_basic (const std::string username_,
|
||||||
const std::string password)
|
const std::string password_)
|
||||||
{
|
{
|
||||||
_auth_method = socks_basic_auth;
|
_auth_method = socks_basic_auth;
|
||||||
_auth_username = username;
|
_auth_username = username_;
|
||||||
_auth_password = password;
|
_auth_password = password_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::socks_connecter_t::in_event ()
|
void zmq::socks_connecter_t::in_event ()
|
||||||
@@ -387,8 +387,8 @@ zmq::fd_t zmq::socks_connecter_t::check_proxy_connection ()
|
|||||||
rc = tune_tcp_socket (_s);
|
rc = tune_tcp_socket (_s);
|
||||||
rc = rc
|
rc = rc
|
||||||
| tune_tcp_keepalives (
|
| tune_tcp_keepalives (
|
||||||
_s, options.tcp_keepalive, options.tcp_keepalive_cnt,
|
_s, options.tcp_keepalive, options.tcp_keepalive_cnt,
|
||||||
options.tcp_keepalive_idle, options.tcp_keepalive_intvl);
|
options.tcp_keepalive_idle, options.tcp_keepalive_intvl);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@@ -169,7 +169,7 @@ void zmq::stream_connecter_base_t::in_event ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void zmq::stream_connecter_base_t::create_engine (
|
void zmq::stream_connecter_base_t::create_engine (
|
||||||
fd_t fd, const std::string &local_address_)
|
fd_t fd_, const std::string &local_address_)
|
||||||
{
|
{
|
||||||
const endpoint_uri_pair_t endpoint_pair (local_address_, _endpoint,
|
const endpoint_uri_pair_t endpoint_pair (local_address_, _endpoint,
|
||||||
endpoint_type_connect);
|
endpoint_type_connect);
|
||||||
@@ -177,9 +177,9 @@ void zmq::stream_connecter_base_t::create_engine (
|
|||||||
// Create the engine object for this connection.
|
// Create the engine object for this connection.
|
||||||
i_engine *engine;
|
i_engine *engine;
|
||||||
if (options.raw_socket)
|
if (options.raw_socket)
|
||||||
engine = new (std::nothrow) raw_engine_t (fd, options, endpoint_pair);
|
engine = new (std::nothrow) raw_engine_t (fd_, options, endpoint_pair);
|
||||||
else
|
else
|
||||||
engine = new (std::nothrow) zmtp_engine_t (fd, options, endpoint_pair);
|
engine = new (std::nothrow) zmtp_engine_t (fd_, options, endpoint_pair);
|
||||||
alloc_assert (engine);
|
alloc_assert (engine);
|
||||||
|
|
||||||
// Attach the engine to the corresponding session object.
|
// Attach the engine to the corresponding session object.
|
||||||
@@ -188,7 +188,7 @@ void zmq::stream_connecter_base_t::create_engine (
|
|||||||
// Shut the connecter down.
|
// Shut the connecter down.
|
||||||
terminate ();
|
terminate ();
|
||||||
|
|
||||||
_socket->event_connected (endpoint_pair, fd);
|
_socket->event_connected (endpoint_pair, fd_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::stream_connecter_base_t::timer_event (int id_)
|
void zmq::stream_connecter_base_t::timer_event (int id_)
|
||||||
|
@@ -97,17 +97,17 @@ int zmq::stream_listener_base_t::close ()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::stream_listener_base_t::create_engine (fd_t fd)
|
void zmq::stream_listener_base_t::create_engine (fd_t fd_)
|
||||||
{
|
{
|
||||||
const endpoint_uri_pair_t endpoint_pair (
|
const endpoint_uri_pair_t endpoint_pair (
|
||||||
get_socket_name (fd, socket_end_local),
|
get_socket_name (fd_, socket_end_local),
|
||||||
get_socket_name (fd, socket_end_remote), endpoint_type_bind);
|
get_socket_name (fd_, socket_end_remote), endpoint_type_bind);
|
||||||
|
|
||||||
i_engine *engine;
|
i_engine *engine;
|
||||||
if (options.raw_socket)
|
if (options.raw_socket)
|
||||||
engine = new (std::nothrow) raw_engine_t (fd, options, endpoint_pair);
|
engine = new (std::nothrow) raw_engine_t (fd_, options, endpoint_pair);
|
||||||
else
|
else
|
||||||
engine = new (std::nothrow) zmtp_engine_t (fd, options, endpoint_pair);
|
engine = new (std::nothrow) zmtp_engine_t (fd_, options, endpoint_pair);
|
||||||
alloc_assert (engine);
|
alloc_assert (engine);
|
||||||
|
|
||||||
// Choose I/O thread to run connecter in. Given that we are already
|
// Choose I/O thread to run connecter in. Given that we are already
|
||||||
@@ -123,5 +123,5 @@ void zmq::stream_listener_base_t::create_engine (fd_t fd)
|
|||||||
launch_child (session);
|
launch_child (session);
|
||||||
send_attach (session, engine, false);
|
send_attach (session, engine, false);
|
||||||
|
|
||||||
_socket->event_accepted (endpoint_pair, fd);
|
_socket->event_accepted (endpoint_pair, fd_);
|
||||||
}
|
}
|
||||||
|
@@ -113,23 +113,23 @@ int zmq::tcp_address_t::resolve (const char *name_, bool local_, bool ipv6_)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <size_t N1, size_t N2>
|
template <size_t N1, size_t N2>
|
||||||
static std::string make_address_string (const char *hbuf,
|
static std::string make_address_string (const char *hbuf_,
|
||||||
uint16_t port,
|
uint16_t port_,
|
||||||
const char (&ipv6_prefix)[N1],
|
const char (&ipv6_prefix_)[N1],
|
||||||
const char (&ipv6_suffix)[N2])
|
const char (&ipv6_suffix_)[N2])
|
||||||
{
|
{
|
||||||
const size_t max_port_str_length = 5;
|
const size_t max_port_str_length = 5;
|
||||||
char buf[NI_MAXHOST + sizeof ipv6_prefix + sizeof ipv6_suffix
|
char buf[NI_MAXHOST + sizeof ipv6_prefix_ + sizeof ipv6_suffix_
|
||||||
+ max_port_str_length];
|
+ max_port_str_length];
|
||||||
char *pos = buf;
|
char *pos = buf;
|
||||||
memcpy (pos, ipv6_prefix, sizeof ipv6_prefix - 1);
|
memcpy (pos, ipv6_prefix_, sizeof ipv6_prefix_ - 1);
|
||||||
pos += sizeof ipv6_prefix - 1;
|
pos += sizeof ipv6_prefix_ - 1;
|
||||||
const size_t hbuf_len = strlen (hbuf);
|
const size_t hbuf_len = strlen (hbuf_);
|
||||||
memcpy (pos, hbuf, hbuf_len);
|
memcpy (pos, hbuf_, hbuf_len);
|
||||||
pos += hbuf_len;
|
pos += hbuf_len;
|
||||||
memcpy (pos, ipv6_suffix, sizeof ipv6_suffix - 1);
|
memcpy (pos, ipv6_suffix_, sizeof ipv6_suffix_ - 1);
|
||||||
pos += sizeof ipv6_suffix - 1;
|
pos += sizeof ipv6_suffix_ - 1;
|
||||||
pos += sprintf (pos, "%d", ntohs (port));
|
pos += sprintf (pos, "%d", ntohs (port_));
|
||||||
return std::string (buf, pos - buf);
|
return std::string (buf, pos - buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -277,10 +277,10 @@ bool zmq::thread_t::is_current_thread () const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void zmq::thread_t::setSchedulingParameters (
|
void zmq::thread_t::setSchedulingParameters (
|
||||||
int priority_, int schedulingPolicy_, const std::set<int> &affinity_cpus_)
|
int priority_, int scheduling_policy_, const std::set<int> &affinity_cpus_)
|
||||||
{
|
{
|
||||||
_thread_priority = priority_;
|
_thread_priority = priority_;
|
||||||
_thread_sched_policy = schedulingPolicy_;
|
_thread_sched_policy = scheduling_policy_;
|
||||||
_thread_affinity_cpus = affinity_cpus_;
|
_thread_affinity_cpus = affinity_cpus_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,13 +44,13 @@ zmq::tipc_address_t::tipc_address_t ()
|
|||||||
_random = false;
|
_random = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
zmq::tipc_address_t::tipc_address_t (const sockaddr *sa, socklen_t sa_len)
|
zmq::tipc_address_t::tipc_address_t (const sockaddr *sa_, socklen_t sa_len_)
|
||||||
{
|
{
|
||||||
zmq_assert (sa && sa_len > 0);
|
zmq_assert (sa_ && sa_len_ > 0);
|
||||||
|
|
||||||
memset (&address, 0, sizeof address);
|
memset (&address, 0, sizeof address);
|
||||||
if (sa->sa_family == AF_TIPC)
|
if (sa_->sa_family == AF_TIPC)
|
||||||
memcpy (&address, sa, sa_len);
|
memcpy (&address, sa_, sa_len_);
|
||||||
|
|
||||||
_random = false;
|
_random = false;
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ bool zmq::tipc_address_t::is_service () const
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int zmq::tipc_address_t::resolve (const char *name)
|
int zmq::tipc_address_t::resolve (const char *name_)
|
||||||
{
|
{
|
||||||
unsigned int type = 0;
|
unsigned int type = 0;
|
||||||
unsigned int lower = 0;
|
unsigned int lower = 0;
|
||||||
@@ -82,7 +82,7 @@ int zmq::tipc_address_t::resolve (const char *name)
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
|
||||||
if (strncmp (name, "<*>", 3) == 0) {
|
if (strncmp (name_, "<*>", 3) == 0) {
|
||||||
set_random ();
|
set_random ();
|
||||||
address.family = AF_TIPC;
|
address.family = AF_TIPC;
|
||||||
address.addrtype = TIPC_ADDR_ID;
|
address.addrtype = TIPC_ADDR_ID;
|
||||||
@@ -92,9 +92,9 @@ int zmq::tipc_address_t::resolve (const char *name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = sscanf (name, "{%u,%u,%u}", &type, &lower, &upper);
|
res = sscanf (name_, "{%u,%u,%u}", &type, &lower, &upper);
|
||||||
/* Fetch optional domain suffix. */
|
/* Fetch optional domain suffix. */
|
||||||
if ((domain = strchr (name, '@'))) {
|
if ((domain = strchr (name_, '@'))) {
|
||||||
if (sscanf (domain, "@%u.%u.%u%c", &z, &c, &n, &eof) != 3)
|
if (sscanf (domain, "@%u.%u.%u%c", &z, &c, &n, &eof) != 3)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ int zmq::tipc_address_t::resolve (const char *name)
|
|||||||
address.scope = 0;
|
address.scope = 0;
|
||||||
return 0;
|
return 0;
|
||||||
} else if (res == 0) {
|
} else if (res == 0) {
|
||||||
res = sscanf (name, "<%u.%u.%u:%u>", &z, &c, &n, &ref);
|
res = sscanf (name_, "<%u.%u.%u:%u>", &z, &c, &n, &ref);
|
||||||
if (res == 4) {
|
if (res == 4) {
|
||||||
address.family = AF_TIPC;
|
address.family = AF_TIPC;
|
||||||
address.addrtype = TIPC_ADDR_ID;
|
address.addrtype = TIPC_ADDR_ID;
|
||||||
|
@@ -270,7 +270,7 @@ bool zmq::ws_connecter_t::tune_socket (const fd_t fd_)
|
|||||||
return rc == 0;
|
return rc == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::ws_connecter_t::create_engine (fd_t fd,
|
void zmq::ws_connecter_t::create_engine (fd_t fd_,
|
||||||
const std::string &local_address_)
|
const std::string &local_address_)
|
||||||
{
|
{
|
||||||
const endpoint_uri_pair_t endpoint_pair (local_address_, _endpoint,
|
const endpoint_uri_pair_t endpoint_pair (local_address_, _endpoint,
|
||||||
@@ -281,14 +281,14 @@ void zmq::ws_connecter_t::create_engine (fd_t fd,
|
|||||||
if (_wss)
|
if (_wss)
|
||||||
#ifdef ZMQ_HAVE_WSS
|
#ifdef ZMQ_HAVE_WSS
|
||||||
engine = new (std::nothrow)
|
engine = new (std::nothrow)
|
||||||
wss_engine_t (fd, options, endpoint_pair, *_addr->resolved.ws_addr,
|
wss_engine_t (fd_, options, endpoint_pair, *_addr->resolved.ws_addr,
|
||||||
true, NULL, _hostname);
|
true, NULL, _hostname);
|
||||||
#else
|
#else
|
||||||
assert (false);
|
assert (false);
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
engine = new (std::nothrow) ws_engine_t (
|
engine = new (std::nothrow) ws_engine_t (
|
||||||
fd, options, endpoint_pair, *_addr->resolved.ws_addr, true);
|
fd_, options, endpoint_pair, *_addr->resolved.ws_addr, true);
|
||||||
alloc_assert (engine);
|
alloc_assert (engine);
|
||||||
|
|
||||||
// Attach the engine to the corresponding session object.
|
// Attach the engine to the corresponding session object.
|
||||||
@@ -297,5 +297,5 @@ void zmq::ws_connecter_t::create_engine (fd_t fd,
|
|||||||
// Shut the connecter down.
|
// Shut the connecter down.
|
||||||
terminate ();
|
terminate ();
|
||||||
|
|
||||||
_socket->event_connected (endpoint_pair, fd);
|
_socket->event_connected (endpoint_pair, fd_);
|
||||||
}
|
}
|
||||||
|
@@ -83,10 +83,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
encode_base64 (const unsigned char *in, int in_len, char *out, int out_len);
|
encode_base64 (const unsigned char *in_, int in_len_, char *out_, int out_len_);
|
||||||
|
|
||||||
static void compute_accept_key (char *key,
|
static void compute_accept_key (char *key_,
|
||||||
unsigned char output[SHA_DIGEST_LENGTH]);
|
unsigned char output_[SHA_DIGEST_LENGTH]);
|
||||||
|
|
||||||
zmq::ws_engine_t::ws_engine_t (fd_t fd_,
|
zmq::ws_engine_t::ws_engine_t (fd_t fd_,
|
||||||
const options_t &options_,
|
const options_t &options_,
|
||||||
@@ -196,22 +196,22 @@ int zmq::ws_engine_t::process_routing_id_msg (msg_t *msg_)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool zmq::ws_engine_t::select_protocol (char *protocol)
|
bool zmq::ws_engine_t::select_protocol (char *protocol_)
|
||||||
{
|
{
|
||||||
if (_options.mechanism == ZMQ_NULL && (strcmp ("ZWS2.0", protocol) == 0)) {
|
if (_options.mechanism == ZMQ_NULL && (strcmp ("ZWS2.0", protocol_) == 0)) {
|
||||||
_next_msg = static_cast<int (stream_engine_base_t::*) (msg_t *)> (
|
_next_msg = static_cast<int (stream_engine_base_t::*) (msg_t *)> (
|
||||||
&ws_engine_t::routing_id_msg);
|
&ws_engine_t::routing_id_msg);
|
||||||
_process_msg = static_cast<int (stream_engine_base_t::*) (msg_t *)> (
|
_process_msg = static_cast<int (stream_engine_base_t::*) (msg_t *)> (
|
||||||
&ws_engine_t::process_routing_id_msg);
|
&ws_engine_t::process_routing_id_msg);
|
||||||
return true;
|
return true;
|
||||||
} else if (_options.mechanism == ZMQ_NULL
|
} else if (_options.mechanism == ZMQ_NULL
|
||||||
&& strcmp ("ZWS2.0/NULL", protocol) == 0) {
|
&& strcmp ("ZWS2.0/NULL", protocol_) == 0) {
|
||||||
_mechanism = new (std::nothrow)
|
_mechanism = new (std::nothrow)
|
||||||
null_mechanism_t (session (), _peer_address, _options);
|
null_mechanism_t (session (), _peer_address, _options);
|
||||||
alloc_assert (_mechanism);
|
alloc_assert (_mechanism);
|
||||||
return true;
|
return true;
|
||||||
} else if (_options.mechanism == ZMQ_PLAIN
|
} else if (_options.mechanism == ZMQ_PLAIN
|
||||||
&& strcmp ("ZWS2.0/PLAIN", protocol) == 0) {
|
&& strcmp ("ZWS2.0/PLAIN", protocol_) == 0) {
|
||||||
if (_options.as_server)
|
if (_options.as_server)
|
||||||
_mechanism = new (std::nothrow)
|
_mechanism = new (std::nothrow)
|
||||||
plain_server_t (session (), _peer_address, _options);
|
plain_server_t (session (), _peer_address, _options);
|
||||||
@@ -223,7 +223,7 @@ bool zmq::ws_engine_t::select_protocol (char *protocol)
|
|||||||
}
|
}
|
||||||
#ifdef ZMQ_HAVE_CURVE
|
#ifdef ZMQ_HAVE_CURVE
|
||||||
else if (_options.mechanism == ZMQ_CURVE
|
else if (_options.mechanism == ZMQ_CURVE
|
||||||
&& strcmp ("ZWS2.0/CURVE", protocol) == 0) {
|
&& strcmp ("ZWS2.0/CURVE", protocol_) == 0) {
|
||||||
if (_options.as_server)
|
if (_options.as_server)
|
||||||
_mechanism = new (std::nothrow)
|
_mechanism = new (std::nothrow)
|
||||||
curve_server_t (session (), _peer_address, _options);
|
curve_server_t (session (), _peer_address, _options);
|
||||||
@@ -877,7 +877,7 @@ bool zmq::ws_engine_t::client_handshake ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
encode_base64 (const unsigned char *in, int in_len, char *out, int out_len)
|
encode_base64 (const unsigned char *in_, int in_len_, char *out_, int out_len_)
|
||||||
{
|
{
|
||||||
static const unsigned char base64enc_tab[65] =
|
static const unsigned char base64enc_tab[65] =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
@@ -886,36 +886,36 @@ encode_base64 (const unsigned char *in, int in_len, char *out, int out_len)
|
|||||||
uint32_t v;
|
uint32_t v;
|
||||||
int rem;
|
int rem;
|
||||||
|
|
||||||
for (io = 0, ii = 0, v = 0, rem = 0; ii < in_len; ii++) {
|
for (io = 0, ii = 0, v = 0, rem = 0; ii < in_len_; ii++) {
|
||||||
unsigned char ch;
|
unsigned char ch;
|
||||||
ch = in[ii];
|
ch = in_[ii];
|
||||||
v = (v << 8) | ch;
|
v = (v << 8) | ch;
|
||||||
rem += 8;
|
rem += 8;
|
||||||
while (rem >= 6) {
|
while (rem >= 6) {
|
||||||
rem -= 6;
|
rem -= 6;
|
||||||
if (io >= out_len)
|
if (io >= out_len_)
|
||||||
return -1; /* truncation is failure */
|
return -1; /* truncation is failure */
|
||||||
out[io++] = base64enc_tab[(v >> rem) & 63];
|
out_[io++] = base64enc_tab[(v >> rem) & 63];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rem) {
|
if (rem) {
|
||||||
v <<= (6 - rem);
|
v <<= (6 - rem);
|
||||||
if (io >= out_len)
|
if (io >= out_len_)
|
||||||
return -1; /* truncation is failure */
|
return -1; /* truncation is failure */
|
||||||
out[io++] = base64enc_tab[v & 63];
|
out_[io++] = base64enc_tab[v & 63];
|
||||||
}
|
}
|
||||||
while (io & 3) {
|
while (io & 3) {
|
||||||
if (io >= out_len)
|
if (io >= out_len_)
|
||||||
return -1; /* truncation is failure */
|
return -1; /* truncation is failure */
|
||||||
out[io++] = '=';
|
out_[io++] = '=';
|
||||||
}
|
}
|
||||||
if (io >= out_len)
|
if (io >= out_len_)
|
||||||
return -1; /* no room for null terminator */
|
return -1; /* no room for null terminator */
|
||||||
out[io] = 0;
|
out_[io] = 0;
|
||||||
return io;
|
return io;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void compute_accept_key (char *key, unsigned char *hash)
|
static void compute_accept_key (char *key_, unsigned char *hash_)
|
||||||
{
|
{
|
||||||
const char *magic_string = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
const char *magic_string = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||||
#ifdef ZMQ_USE_NSS
|
#ifdef ZMQ_USE_NSS
|
||||||
@@ -925,24 +925,24 @@ static void compute_accept_key (char *key, unsigned char *hash)
|
|||||||
assert (ctx);
|
assert (ctx);
|
||||||
|
|
||||||
HASH_Begin (ctx);
|
HASH_Begin (ctx);
|
||||||
HASH_Update (ctx, (unsigned char *) key, (unsigned int) strlen (key));
|
HASH_Update (ctx, (unsigned char *) key_, (unsigned int) strlen (key_));
|
||||||
HASH_Update (ctx, (unsigned char *) magic_string,
|
HASH_Update (ctx, (unsigned char *) magic_string,
|
||||||
(unsigned int) strlen (magic_string));
|
(unsigned int) strlen (magic_string));
|
||||||
HASH_End (ctx, hash, &len, SHA_DIGEST_LENGTH);
|
HASH_End (ctx, hash_, &len, SHA_DIGEST_LENGTH);
|
||||||
HASH_Destroy (ctx);
|
HASH_Destroy (ctx);
|
||||||
#elif defined ZMQ_USE_BUILTIN_SHA1
|
#elif defined ZMQ_USE_BUILTIN_SHA1
|
||||||
sha1_ctxt ctx;
|
sha1_ctxt ctx;
|
||||||
SHA1_Init (&ctx);
|
SHA1_Init (&ctx);
|
||||||
SHA1_Update (&ctx, (unsigned char *) key, strlen (key));
|
SHA1_Update (&ctx, (unsigned char *) key_, strlen (key_));
|
||||||
SHA1_Update (&ctx, (unsigned char *) magic_string, strlen (magic_string));
|
SHA1_Update (&ctx, (unsigned char *) magic_string, strlen (magic_string));
|
||||||
|
|
||||||
SHA1_Final (hash, &ctx);
|
SHA1_Final (hash_, &ctx);
|
||||||
#elif defined ZMQ_USE_GNUTLS
|
#elif defined ZMQ_USE_GNUTLS
|
||||||
gnutls_hash_hd_t hd;
|
gnutls_hash_hd_t hd;
|
||||||
gnutls_hash_init (&hd, GNUTLS_DIG_SHA1);
|
gnutls_hash_init (&hd, GNUTLS_DIG_SHA1);
|
||||||
gnutls_hash (hd, key, strlen (key));
|
gnutls_hash (hd, key_, strlen (key_));
|
||||||
gnutls_hash (hd, magic_string, strlen (magic_string));
|
gnutls_hash (hd, magic_string, strlen (magic_string));
|
||||||
gnutls_hash_deinit (hd, hash);
|
gnutls_hash_deinit (hd, hash_);
|
||||||
#else
|
#else
|
||||||
#error "No sha1 implementation set"
|
#error "No sha1 implementation set"
|
||||||
#endif
|
#endif
|
||||||
|
@@ -285,23 +285,23 @@ zmq::fd_t zmq::ws_listener_t::accept ()
|
|||||||
return sock;
|
return sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::ws_listener_t::create_engine (fd_t fd)
|
void zmq::ws_listener_t::create_engine (fd_t fd_)
|
||||||
{
|
{
|
||||||
const endpoint_uri_pair_t endpoint_pair (
|
const endpoint_uri_pair_t endpoint_pair (
|
||||||
get_socket_name (fd, socket_end_local),
|
get_socket_name (fd_, socket_end_local),
|
||||||
get_socket_name (fd, socket_end_remote), endpoint_type_bind);
|
get_socket_name (fd_, socket_end_remote), endpoint_type_bind);
|
||||||
|
|
||||||
i_engine *engine = NULL;
|
i_engine *engine = NULL;
|
||||||
if (_wss)
|
if (_wss)
|
||||||
#ifdef ZMQ_HAVE_WSS
|
#ifdef ZMQ_HAVE_WSS
|
||||||
engine = new (std::nothrow) wss_engine_t (
|
engine = new (std::nothrow) wss_engine_t (
|
||||||
fd, options, endpoint_pair, _address, false, _tls_cred, NULL);
|
fd_, options, endpoint_pair, _address, false, _tls_cred, NULL);
|
||||||
#else
|
#else
|
||||||
assert (false);
|
assert (false);
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
engine = new (std::nothrow)
|
engine = new (std::nothrow)
|
||||||
ws_engine_t (fd, options, endpoint_pair, _address, false);
|
ws_engine_t (fd_, options, endpoint_pair, _address, false);
|
||||||
alloc_assert (engine);
|
alloc_assert (engine);
|
||||||
|
|
||||||
// Choose I/O thread to run connecter in. Given that we are already
|
// Choose I/O thread to run connecter in. Given that we are already
|
||||||
@@ -317,5 +317,5 @@ void zmq::ws_listener_t::create_engine (fd_t fd)
|
|||||||
launch_child (session);
|
launch_child (session);
|
||||||
send_attach (session, engine, false);
|
send_attach (session, engine, false);
|
||||||
|
|
||||||
_socket->event_accepted (endpoint_pair, fd);
|
_socket->event_accepted (endpoint_pair, fd_);
|
||||||
}
|
}
|
||||||
|
@@ -194,10 +194,10 @@ int zmq_ctx_set_ext (void *ctx_,
|
|||||||
|
|
||||||
int zmq_ctx_get (void *ctx_, int option_)
|
int zmq_ctx_get (void *ctx_, int option_)
|
||||||
{
|
{
|
||||||
int optval_ = 0;
|
int optval = 0;
|
||||||
size_t optvallen_ = sizeof (int);
|
size_t optvallen = sizeof (int);
|
||||||
if (zmq_ctx_get_ext (ctx_, option_, &optval_, &optvallen_) == 0) {
|
if (zmq_ctx_get_ext (ctx_, option_, &optval, &optvallen) == 0) {
|
||||||
return optval_;
|
return optval;
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
|
@@ -229,14 +229,14 @@ void zmq::zmtp_engine_t::receive_greeting_versioned ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
zmq::zmtp_engine_t::handshake_fun_t
|
zmq::zmtp_engine_t::handshake_fun_t
|
||||||
zmq::zmtp_engine_t::select_handshake_fun (bool unversioned,
|
zmq::zmtp_engine_t::select_handshake_fun (bool unversioned_,
|
||||||
unsigned char revision)
|
unsigned char revision_)
|
||||||
{
|
{
|
||||||
// Is the peer using ZMTP/1.0 with no revision number?
|
// Is the peer using ZMTP/1.0 with no revision number?
|
||||||
if (unversioned) {
|
if (unversioned_) {
|
||||||
return &zmtp_engine_t::handshake_v1_0_unversioned;
|
return &zmtp_engine_t::handshake_v1_0_unversioned;
|
||||||
}
|
}
|
||||||
switch (revision) {
|
switch (revision_) {
|
||||||
case ZMTP_1_0:
|
case ZMTP_1_0:
|
||||||
return &zmtp_engine_t::handshake_v1_0;
|
return &zmtp_engine_t::handshake_v1_0;
|
||||||
case ZMTP_2_0:
|
case ZMTP_2_0:
|
||||||
|
@@ -38,13 +38,13 @@
|
|||||||
|
|
||||||
SETUP_TEARDOWN_TESTCONTEXT
|
SETUP_TEARDOWN_TESTCONTEXT
|
||||||
|
|
||||||
int test_defaults (int send_hwm_, int msg_cnt_, const char *endpoint)
|
int test_defaults (int send_hwm_, int msg_cnt_, const char *endpoint_)
|
||||||
{
|
{
|
||||||
char pub_endpoint[SOCKET_STRING_LEN];
|
char pub_endpoint[SOCKET_STRING_LEN];
|
||||||
|
|
||||||
// Set up and bind XPUB socket
|
// Set up and bind XPUB socket
|
||||||
void *pub_socket = test_context_socket (ZMQ_XPUB);
|
void *pub_socket = test_context_socket (ZMQ_XPUB);
|
||||||
test_bind (pub_socket, endpoint, pub_endpoint, sizeof pub_endpoint);
|
test_bind (pub_socket, endpoint_, pub_endpoint, sizeof pub_endpoint);
|
||||||
|
|
||||||
// Set up and connect SUB socket
|
// Set up and connect SUB socket
|
||||||
void *sub_socket = test_context_socket (ZMQ_SUB);
|
void *sub_socket = test_context_socket (ZMQ_SUB);
|
||||||
@@ -86,10 +86,10 @@ int test_defaults (int send_hwm_, int msg_cnt_, const char *endpoint)
|
|||||||
return recv_count;
|
return recv_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int receive (void *socket_, int *is_termination)
|
int receive (void *socket_, int *is_termination_)
|
||||||
{
|
{
|
||||||
int recv_count = 0;
|
int recv_count = 0;
|
||||||
*is_termination = 0;
|
*is_termination_ = 0;
|
||||||
|
|
||||||
// Now receive all sent messages
|
// Now receive all sent messages
|
||||||
char buffer[255];
|
char buffer[255];
|
||||||
@@ -98,7 +98,7 @@ int receive (void *socket_, int *is_termination)
|
|||||||
++recv_count;
|
++recv_count;
|
||||||
|
|
||||||
if (len == 3 && strncmp (buffer, "end", len) == 0) {
|
if (len == 3 && strncmp (buffer, "end", len) == 0) {
|
||||||
*is_termination = 1;
|
*is_termination_ = 1;
|
||||||
return recv_count;
|
return recv_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,13 +106,13 @@ int receive (void *socket_, int *is_termination)
|
|||||||
return recv_count;
|
return recv_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_blocking (int send_hwm_, int msg_cnt_, const char *endpoint)
|
int test_blocking (int send_hwm_, int msg_cnt_, const char *endpoint_)
|
||||||
{
|
{
|
||||||
char pub_endpoint[SOCKET_STRING_LEN];
|
char pub_endpoint[SOCKET_STRING_LEN];
|
||||||
|
|
||||||
// Set up bind socket
|
// Set up bind socket
|
||||||
void *pub_socket = test_context_socket (ZMQ_XPUB);
|
void *pub_socket = test_context_socket (ZMQ_XPUB);
|
||||||
test_bind (pub_socket, endpoint, pub_endpoint, sizeof pub_endpoint);
|
test_bind (pub_socket, endpoint_, pub_endpoint, sizeof pub_endpoint);
|
||||||
|
|
||||||
// Set up connect socket
|
// Set up connect socket
|
||||||
void *sub_socket = test_context_socket (ZMQ_SUB);
|
void *sub_socket = test_context_socket (ZMQ_SUB);
|
||||||
|
@@ -136,7 +136,7 @@ static void prep_server_socket (void **server_out_,
|
|||||||
*mon_out_ = server_mon;
|
*mon_out_ = server_mon;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_mock_sub (bool sub_command)
|
static void test_mock_sub (bool sub_command_)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
char my_endpoint[MAX_SOCKET_STRING];
|
char my_endpoint[MAX_SOCKET_STRING];
|
||||||
@@ -167,7 +167,7 @@ static void test_mock_sub (bool sub_command)
|
|||||||
rc = get_monitor_event (server_mon);
|
rc = get_monitor_event (server_mon);
|
||||||
TEST_ASSERT_EQUAL_INT (ZMQ_EVENT_ACCEPTED, rc);
|
TEST_ASSERT_EQUAL_INT (ZMQ_EVENT_ACCEPTED, rc);
|
||||||
|
|
||||||
if (sub_command) {
|
if (sub_command_) {
|
||||||
const uint8_t sub[13] = {4, 11, 9, 'S', 'U', 'B', 'S',
|
const uint8_t sub[13] = {4, 11, 9, 'S', 'U', 'B', 'S',
|
||||||
'C', 'R', 'I', 'B', 'E', 'A'};
|
'C', 'R', 'I', 'B', 'E', 'A'};
|
||||||
rc =
|
rc =
|
||||||
|
@@ -196,12 +196,12 @@ void test_monitor_versioned_basic (bind_function_t bind_function_,
|
|||||||
// Now do a basic ping test
|
// Now do a basic ping test
|
||||||
bind_function_ (server, server_endpoint, sizeof server_endpoint);
|
bind_function_ (server, server_endpoint, sizeof server_endpoint);
|
||||||
|
|
||||||
int ipv6_;
|
int ipv6;
|
||||||
size_t ipv6_size_ = sizeof (ipv6_);
|
size_t ipv6_size = sizeof (ipv6);
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
zmq_getsockopt (server, ZMQ_IPV6, &ipv6_, &ipv6_size_));
|
zmq_getsockopt (server, ZMQ_IPV6, &ipv6, &ipv6_size));
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
zmq_setsockopt (client, ZMQ_IPV6, &ipv6_, sizeof (int)));
|
zmq_setsockopt (client, ZMQ_IPV6, &ipv6, sizeof (int)));
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (client, server_endpoint));
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (client, server_endpoint));
|
||||||
bounce (server, client);
|
bounce (server, client);
|
||||||
|
|
||||||
@@ -327,14 +327,14 @@ void test_monitor_versioned_stats (bind_function_t bind_function_,
|
|||||||
push, ZMQ_SNDBUF, &tcp_buffer_size, sizeof (tcp_buffer_size)));
|
push, ZMQ_SNDBUF, &tcp_buffer_size, sizeof (tcp_buffer_size)));
|
||||||
bind_function_ (push, server_endpoint, sizeof (server_endpoint));
|
bind_function_ (push, server_endpoint, sizeof (server_endpoint));
|
||||||
|
|
||||||
int ipv6_;
|
int ipv6;
|
||||||
size_t ipv6_size_ = sizeof (ipv6_);
|
size_t ipv6_size = sizeof (ipv6);
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
zmq_getsockopt (push, ZMQ_IPV6, &ipv6_, &ipv6_size_));
|
zmq_getsockopt (push, ZMQ_IPV6, &ipv6, &ipv6_size));
|
||||||
for (int i = 0; i < pulls_count; ++i) {
|
for (int i = 0; i < pulls_count; ++i) {
|
||||||
pulls[i] = test_context_socket (ZMQ_PULL);
|
pulls[i] = test_context_socket (ZMQ_PULL);
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
zmq_setsockopt (pulls[i], ZMQ_IPV6, &ipv6_, sizeof (int)));
|
zmq_setsockopt (pulls[i], ZMQ_IPV6, &ipv6, sizeof (int)));
|
||||||
int timeout_ms = 10;
|
int timeout_ms = 10;
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (
|
||||||
pulls[i], ZMQ_RCVTIMEO, &timeout_ms, sizeof (timeout_ms)));
|
pulls[i], ZMQ_RCVTIMEO, &timeout_ms, sizeof (timeout_ms)));
|
||||||
|
@@ -71,19 +71,19 @@ typedef struct
|
|||||||
void *subscriber_received_all;
|
void *subscriber_received_all;
|
||||||
} proxy_hwm_cfg_t;
|
} proxy_hwm_cfg_t;
|
||||||
|
|
||||||
static void lower_hwm (void *skt)
|
static void lower_hwm (void *skt_)
|
||||||
{
|
{
|
||||||
int send_hwm_ = HWM;
|
int send_hwm = HWM;
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
zmq_setsockopt (skt, ZMQ_SNDHWM, &send_hwm_, sizeof (send_hwm_)));
|
zmq_setsockopt (skt_, ZMQ_SNDHWM, &send_hwm, sizeof (send_hwm)));
|
||||||
|
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
zmq_setsockopt (skt, ZMQ_RCVHWM, &send_hwm_, sizeof (send_hwm_)));
|
zmq_setsockopt (skt_, ZMQ_RCVHWM, &send_hwm, sizeof (send_hwm)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void publisher_thread_main (void *pvoid)
|
static void publisher_thread_main (void *pvoid_)
|
||||||
{
|
{
|
||||||
proxy_hwm_cfg_t *cfg = (proxy_hwm_cfg_t *) pvoid;
|
proxy_hwm_cfg_t *cfg = (proxy_hwm_cfg_t *) pvoid_;
|
||||||
|
|
||||||
void *pubsocket = zmq_socket (cfg->context, ZMQ_XPUB);
|
void *pubsocket = zmq_socket (cfg->context, ZMQ_XPUB);
|
||||||
assert (pubsocket);
|
assert (pubsocket);
|
||||||
@@ -136,9 +136,9 @@ static void publisher_thread_main (void *pvoid)
|
|||||||
zmq_close (pubsocket);
|
zmq_close (pubsocket);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void subscriber_thread_main (void *pvoid)
|
static void subscriber_thread_main (void *pvoid_)
|
||||||
{
|
{
|
||||||
proxy_hwm_cfg_t *cfg = (proxy_hwm_cfg_t *) pvoid;
|
proxy_hwm_cfg_t *cfg = (proxy_hwm_cfg_t *) pvoid_;
|
||||||
|
|
||||||
void *subsocket = zmq_socket (cfg->context, ZMQ_SUB);
|
void *subsocket = zmq_socket (cfg->context, ZMQ_SUB);
|
||||||
assert (subsocket);
|
assert (subsocket);
|
||||||
@@ -190,7 +190,7 @@ static void subscriber_thread_main (void *pvoid)
|
|||||||
zmq_close (subsocket);
|
zmq_close (subsocket);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool recv_stat (void *sock_, bool last_, uint64_t *res)
|
bool recv_stat (void *sock_, bool last_, uint64_t *res_)
|
||||||
{
|
{
|
||||||
zmq_msg_t stats_msg;
|
zmq_msg_t stats_msg;
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ bool recv_stat (void *sock_, bool last_, uint64_t *res)
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert (rc == sizeof (uint64_t));
|
assert (rc == sizeof (uint64_t));
|
||||||
memcpy (res, zmq_msg_data (&stats_msg), zmq_msg_size (&stats_msg));
|
memcpy (res_, zmq_msg_data (&stats_msg), zmq_msg_size (&stats_msg));
|
||||||
|
|
||||||
rc = zmq_msg_close (&stats_msg);
|
rc = zmq_msg_close (&stats_msg);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
@@ -264,9 +264,9 @@ bool check_proxy_stats (void *control_proxy_)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void proxy_stats_asker_thread_main (void *pvoid)
|
static void proxy_stats_asker_thread_main (void *pvoid_)
|
||||||
{
|
{
|
||||||
proxy_hwm_cfg_t *cfg = (proxy_hwm_cfg_t *) pvoid;
|
proxy_hwm_cfg_t *cfg = (proxy_hwm_cfg_t *) pvoid_;
|
||||||
|
|
||||||
|
|
||||||
// CONTROL REQ
|
// CONTROL REQ
|
||||||
@@ -316,9 +316,9 @@ static void proxy_stats_asker_thread_main (void *pvoid)
|
|||||||
zmq_close (control_req);
|
zmq_close (control_req);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void proxy_thread_main (void *pvoid)
|
static void proxy_thread_main (void *pvoid_)
|
||||||
{
|
{
|
||||||
proxy_hwm_cfg_t *cfg = (proxy_hwm_cfg_t *) pvoid;
|
proxy_hwm_cfg_t *cfg = (proxy_hwm_cfg_t *) pvoid_;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -136,7 +136,7 @@ void test_sockopt_router_notify ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void test_router_notify_helper (int opt_notify)
|
void test_router_notify_helper (int opt_notify_)
|
||||||
{
|
{
|
||||||
void *router = test_context_socket (ZMQ_ROUTER);
|
void *router = test_context_socket (ZMQ_ROUTER);
|
||||||
int opt_more;
|
int opt_more;
|
||||||
@@ -148,7 +148,7 @@ void test_router_notify_helper (int opt_notify)
|
|||||||
|
|
||||||
// valid values
|
// valid values
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (
|
||||||
router, ZMQ_ROUTER_NOTIFY, &opt_notify, sizeof (opt_notify)));
|
router, ZMQ_ROUTER_NOTIFY, &opt_notify_, sizeof (opt_notify_)));
|
||||||
|
|
||||||
bind_loopback_ipv4 (router, connect_address, sizeof connect_address);
|
bind_loopback_ipv4 (router, connect_address, sizeof connect_address);
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ void test_router_notify_helper (int opt_notify)
|
|||||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (dealer, connect_address));
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (dealer, connect_address));
|
||||||
|
|
||||||
// connection notification msg
|
// connection notification msg
|
||||||
if (opt_notify & ZMQ_NOTIFY_CONNECT) {
|
if (opt_notify_ & ZMQ_NOTIFY_CONNECT) {
|
||||||
// routing-id only message of the connect
|
// routing-id only message of the connect
|
||||||
recv_string_expect_success (router, dealer_routing_id,
|
recv_string_expect_success (router, dealer_routing_id,
|
||||||
0); // 1st part: routing-id
|
0); // 1st part: routing-id
|
||||||
@@ -188,7 +188,7 @@ void test_router_notify_helper (int opt_notify)
|
|||||||
zmq_getsockopt (dealer, ZMQ_EVENTS, &opt_events, &opt_events_length);
|
zmq_getsockopt (dealer, ZMQ_EVENTS, &opt_events, &opt_events_length);
|
||||||
|
|
||||||
// connection notification msg
|
// connection notification msg
|
||||||
if (opt_notify & ZMQ_NOTIFY_DISCONNECT) {
|
if (opt_notify_ & ZMQ_NOTIFY_DISCONNECT) {
|
||||||
// routing-id only message of the connect
|
// routing-id only message of the connect
|
||||||
recv_string_expect_success (router, dealer_routing_id,
|
recv_string_expect_success (router, dealer_routing_id,
|
||||||
0); // 1st part: routing-id
|
0); // 1st part: routing-id
|
||||||
|
@@ -237,7 +237,7 @@ void test_destroy_queue_on_disconnect (const char *bind_address_)
|
|||||||
|
|
||||||
// PUSH and PULL: SHALL either receive or drop multipart messages atomically.
|
// PUSH and PULL: SHALL either receive or drop multipart messages atomically.
|
||||||
void test_push_multipart_atomic_drop (const char *bind_address_,
|
void test_push_multipart_atomic_drop (const char *bind_address_,
|
||||||
const bool block)
|
const bool block_)
|
||||||
{
|
{
|
||||||
int linger = 0;
|
int linger = 0;
|
||||||
int hwm = 1;
|
int hwm = 1;
|
||||||
@@ -312,7 +312,7 @@ void test_push_multipart_atomic_drop (const char *bind_address_,
|
|||||||
send_string_expect_success (push, "3", ZMQ_SNDMORE);
|
send_string_expect_success (push, "3", ZMQ_SNDMORE);
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init_size (&msg_data, len));
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init_size (&msg_data, len));
|
||||||
memset (zmq_msg_data (&msg_data), 'c', len);
|
memset (zmq_msg_data (&msg_data), 'c', len);
|
||||||
if (block) {
|
if (block_) {
|
||||||
TEST_ASSERT_EQUAL_INT (len,
|
TEST_ASSERT_EQUAL_INT (len,
|
||||||
zmq_msg_send (&msg_data, push, ZMQ_SNDMORE));
|
zmq_msg_send (&msg_data, push, ZMQ_SNDMORE));
|
||||||
} else {
|
} else {
|
||||||
|
@@ -36,7 +36,7 @@ SETUP_TEARDOWN_TESTCONTEXT
|
|||||||
|
|
||||||
char connect_address[MAX_SOCKET_STRING];
|
char connect_address[MAX_SOCKET_STRING];
|
||||||
|
|
||||||
void test_fair_queue_in (const char *bind_address)
|
void test_fair_queue_in (const char *bind_address_)
|
||||||
{
|
{
|
||||||
void *rep = test_context_socket (ZMQ_REP);
|
void *rep = test_context_socket (ZMQ_REP);
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ void test_fair_queue_in (const char *bind_address)
|
|||||||
TEST_ASSERT_SUCCESS_ERRNO (
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
zmq_setsockopt (rep, ZMQ_RCVTIMEO, &timeout, sizeof (int)));
|
zmq_setsockopt (rep, ZMQ_RCVTIMEO, &timeout, sizeof (int)));
|
||||||
|
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (rep, bind_address));
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (rep, bind_address_));
|
||||||
size_t len = MAX_SOCKET_STRING;
|
size_t len = MAX_SOCKET_STRING;
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
zmq_getsockopt (rep, ZMQ_LAST_ENDPOINT, connect_address, &len));
|
zmq_getsockopt (rep, ZMQ_LAST_ENDPOINT, connect_address, &len));
|
||||||
@@ -98,11 +98,11 @@ void test_fair_queue_in (const char *bind_address)
|
|||||||
test_context_socket_close_zero_linger (reqs[peer]);
|
test_context_socket_close_zero_linger (reqs[peer]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_envelope (const char *bind_address)
|
void test_envelope (const char *bind_address_)
|
||||||
{
|
{
|
||||||
void *rep = test_context_socket (ZMQ_REP);
|
void *rep = test_context_socket (ZMQ_REP);
|
||||||
|
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (rep, bind_address));
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (rep, bind_address_));
|
||||||
size_t len = MAX_SOCKET_STRING;
|
size_t len = MAX_SOCKET_STRING;
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
zmq_getsockopt (rep, ZMQ_LAST_ENDPOINT, connect_address, &len));
|
zmq_getsockopt (rep, ZMQ_LAST_ENDPOINT, connect_address, &len));
|
||||||
|
@@ -37,7 +37,7 @@ SETUP_TEARDOWN_TESTCONTEXT
|
|||||||
|
|
||||||
// SHALL receive incoming messages from its peers using a fair-queuing
|
// SHALL receive incoming messages from its peers using a fair-queuing
|
||||||
// strategy.
|
// strategy.
|
||||||
void test_fair_queue_in (const char *bind_address)
|
void test_fair_queue_in (const char *bind_address_)
|
||||||
{
|
{
|
||||||
char connect_address[MAX_SOCKET_STRING];
|
char connect_address[MAX_SOCKET_STRING];
|
||||||
void *receiver = test_context_socket (ZMQ_ROUTER);
|
void *receiver = test_context_socket (ZMQ_ROUTER);
|
||||||
@@ -46,7 +46,7 @@ void test_fair_queue_in (const char *bind_address)
|
|||||||
TEST_ASSERT_SUCCESS_ERRNO (
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
zmq_setsockopt (receiver, ZMQ_RCVTIMEO, &timeout, sizeof (int)));
|
zmq_setsockopt (receiver, ZMQ_RCVTIMEO, &timeout, sizeof (int)));
|
||||||
|
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (receiver, bind_address));
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (receiver, bind_address_));
|
||||||
size_t len = MAX_SOCKET_STRING;
|
size_t len = MAX_SOCKET_STRING;
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
zmq_getsockopt (receiver, ZMQ_LAST_ENDPOINT, connect_address, &len));
|
zmq_getsockopt (receiver, ZMQ_LAST_ENDPOINT, connect_address, &len));
|
||||||
@@ -116,7 +116,7 @@ void test_fair_queue_in (const char *bind_address)
|
|||||||
// SHALL create a double queue when a peer connects to it. If this peer
|
// SHALL create a double queue when a peer connects to it. If this peer
|
||||||
// disconnects, the ROUTER socket SHALL destroy its double queue and SHALL
|
// disconnects, the ROUTER socket SHALL destroy its double queue and SHALL
|
||||||
// discard any messages it contains.
|
// discard any messages it contains.
|
||||||
void test_destroy_queue_on_disconnect (const char *bind_address)
|
void test_destroy_queue_on_disconnect (const char *bind_address_)
|
||||||
{
|
{
|
||||||
void *a = test_context_socket (ZMQ_ROUTER);
|
void *a = test_context_socket (ZMQ_ROUTER);
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ void test_destroy_queue_on_disconnect (const char *bind_address)
|
|||||||
TEST_ASSERT_SUCCESS_ERRNO (
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
zmq_setsockopt (a, ZMQ_ROUTER_MANDATORY, &enabled, sizeof (enabled)));
|
zmq_setsockopt (a, ZMQ_ROUTER_MANDATORY, &enabled, sizeof (enabled)));
|
||||||
|
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (a, bind_address));
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (a, bind_address_));
|
||||||
size_t len = MAX_SOCKET_STRING;
|
size_t len = MAX_SOCKET_STRING;
|
||||||
char connect_address[MAX_SOCKET_STRING];
|
char connect_address[MAX_SOCKET_STRING];
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
|
@@ -342,7 +342,7 @@ int test_inet_pton (int af_, const char *src_, void *dst_)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
sockaddr_in bind_bsd_socket (int socket)
|
sockaddr_in bind_bsd_socket (int socket_)
|
||||||
{
|
{
|
||||||
struct sockaddr_in saddr;
|
struct sockaddr_in saddr;
|
||||||
memset (&saddr, 0, sizeof (saddr));
|
memset (&saddr, 0, sizeof (saddr));
|
||||||
@@ -355,23 +355,23 @@ sockaddr_in bind_bsd_socket (int socket)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEST_ASSERT_SUCCESS_RAW_ERRNO (
|
TEST_ASSERT_SUCCESS_RAW_ERRNO (
|
||||||
bind (socket, (struct sockaddr *) &saddr, sizeof (saddr)));
|
bind (socket_, (struct sockaddr *) &saddr, sizeof (saddr)));
|
||||||
|
|
||||||
#if !defined(_WIN32_WINNT) || (_WIN32_WINNT >= 0x0600)
|
#if !defined(_WIN32_WINNT) || (_WIN32_WINNT >= 0x0600)
|
||||||
socklen_t saddr_len = sizeof (saddr);
|
socklen_t saddr_len = sizeof (saddr);
|
||||||
TEST_ASSERT_SUCCESS_RAW_ERRNO (
|
TEST_ASSERT_SUCCESS_RAW_ERRNO (
|
||||||
getsockname (socket, (struct sockaddr *) &saddr, &saddr_len));
|
getsockname (socket_, (struct sockaddr *) &saddr, &saddr_len));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return saddr;
|
return saddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool streq (const char *lhs, const char *rhs)
|
bool streq (const char *lhs_, const char *rhs_)
|
||||||
{
|
{
|
||||||
return strcmp (lhs, rhs) == 0;
|
return strcmp (lhs_, rhs_) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool strneq (const char *lhs, const char *rhs)
|
bool strneq (const char *lhs_, const char *rhs_)
|
||||||
{
|
{
|
||||||
return strcmp (lhs, rhs) != 0;
|
return strcmp (lhs_, rhs_) != 0;
|
||||||
}
|
}
|
||||||
|
@@ -40,7 +40,7 @@
|
|||||||
int test_assert_success_message_errno_helper (int rc_,
|
int test_assert_success_message_errno_helper (int rc_,
|
||||||
const char *msg_,
|
const char *msg_,
|
||||||
const char *expr_,
|
const char *expr_,
|
||||||
int line)
|
int line_)
|
||||||
{
|
{
|
||||||
if (rc_ == -1) {
|
if (rc_ == -1) {
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
@@ -50,7 +50,7 @@ int test_assert_success_message_errno_helper (int rc_,
|
|||||||
"%s failed%s%s%s, errno = %i (%s)", expr_,
|
"%s failed%s%s%s, errno = %i (%s)", expr_,
|
||||||
msg_ ? " (additional info: " : "", msg_ ? msg_ : "",
|
msg_ ? " (additional info: " : "", msg_ ? msg_ : "",
|
||||||
msg_ ? ")" : "", zmq_errno (), zmq_strerror (zmq_errno ()));
|
msg_ ? ")" : "", zmq_errno (), zmq_strerror (zmq_errno ()));
|
||||||
UNITY_TEST_FAIL (line, buffer);
|
UNITY_TEST_FAIL (line_, buffer);
|
||||||
}
|
}
|
||||||
return rc_;
|
return rc_;
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ int test_assert_success_message_errno_helper (int rc_,
|
|||||||
int test_assert_success_message_raw_errno_helper (int rc_,
|
int test_assert_success_message_raw_errno_helper (int rc_,
|
||||||
const char *msg_,
|
const char *msg_,
|
||||||
const char *expr_,
|
const char *expr_,
|
||||||
int line)
|
int line_)
|
||||||
{
|
{
|
||||||
if (rc_ == -1) {
|
if (rc_ == -1) {
|
||||||
#if defined ZMQ_HAVE_WINDOWS
|
#if defined ZMQ_HAVE_WINDOWS
|
||||||
@@ -73,13 +73,13 @@ int test_assert_success_message_raw_errno_helper (int rc_,
|
|||||||
snprintf (buffer, sizeof (buffer) - 1, "%s failed%s%s%s, errno = %i",
|
snprintf (buffer, sizeof (buffer) - 1, "%s failed%s%s%s, errno = %i",
|
||||||
expr_, msg_ ? " (additional info: " : "", msg_ ? msg_ : "",
|
expr_, msg_ ? " (additional info: " : "", msg_ ? msg_ : "",
|
||||||
msg_ ? ")" : "", current_errno);
|
msg_ ? ")" : "", current_errno);
|
||||||
UNITY_TEST_FAIL (line, buffer);
|
UNITY_TEST_FAIL (line_, buffer);
|
||||||
}
|
}
|
||||||
return rc_;
|
return rc_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_assert_failure_message_raw_errno_helper (
|
int test_assert_failure_message_raw_errno_helper (
|
||||||
int rc_, int expected_errno_, const char *msg_, const char *expr_, int line)
|
int rc_, int expected_errno_, const char *msg_, const char *expr_, int line_)
|
||||||
{
|
{
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
buffer[sizeof (buffer) - 1] =
|
buffer[sizeof (buffer) - 1] =
|
||||||
@@ -90,7 +90,7 @@ int test_assert_failure_message_raw_errno_helper (
|
|||||||
"errno = %i, actual return value = %i",
|
"errno = %i, actual return value = %i",
|
||||||
expr_, msg_ ? " (additional info: " : "", msg_ ? msg_ : "",
|
expr_, msg_ ? " (additional info: " : "", msg_ ? msg_ : "",
|
||||||
msg_ ? ")" : "", expected_errno_, rc_);
|
msg_ ? ")" : "", expected_errno_, rc_);
|
||||||
UNITY_TEST_FAIL (line, buffer);
|
UNITY_TEST_FAIL (line_, buffer);
|
||||||
} else {
|
} else {
|
||||||
#if defined ZMQ_HAVE_WINDOWS
|
#if defined ZMQ_HAVE_WINDOWS
|
||||||
int current_errno = WSAGetLastError ();
|
int current_errno = WSAGetLastError ();
|
||||||
@@ -104,7 +104,7 @@ int test_assert_failure_message_raw_errno_helper (
|
|||||||
expr_, msg_ ? " (additional info: " : "",
|
expr_, msg_ ? " (additional info: " : "",
|
||||||
msg_ ? msg_ : "", msg_ ? ")" : "", expected_errno_,
|
msg_ ? msg_ : "", msg_ ? ")" : "", expected_errno_,
|
||||||
current_errno);
|
current_errno);
|
||||||
UNITY_TEST_FAIL (line, buffer);
|
UNITY_TEST_FAIL (line_, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rc_;
|
return rc_;
|
||||||
|
@@ -34,9 +34,9 @@ void tearDown ()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int getlen (const zmq::generic_mtrie_t<int>::prefix_t &data)
|
int getlen (const zmq::generic_mtrie_t<int>::prefix_t &data_)
|
||||||
{
|
{
|
||||||
return (int) strlen (reinterpret_cast<const char *> (data));
|
return (int) strlen (reinterpret_cast<const char *> (data_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_create ()
|
void test_create ()
|
||||||
@@ -44,10 +44,10 @@ void test_create ()
|
|||||||
zmq::generic_mtrie_t<int> mtrie;
|
zmq::generic_mtrie_t<int> mtrie;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mtrie_count (int *pipe, int *count)
|
void mtrie_count (int *pipe_, int *count_)
|
||||||
{
|
{
|
||||||
LIBZMQ_UNUSED (pipe);
|
LIBZMQ_UNUSED (pipe_);
|
||||||
++*count;
|
++*count_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_check_empty_match_nonempty_data ()
|
void test_check_empty_match_nonempty_data ()
|
||||||
@@ -187,14 +187,14 @@ void test_rm_nonexistent_empty ()
|
|||||||
TEST_ASSERT_EQUAL_INT (0, count);
|
TEST_ASSERT_EQUAL_INT (0, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_add_and_rm_other (const char *add_name, const char *rm_name)
|
void test_add_and_rm_other (const char *add_name_, const char *rm_name_)
|
||||||
{
|
{
|
||||||
int addpipe, rmpipe;
|
int addpipe, rmpipe;
|
||||||
zmq::generic_mtrie_t<int> mtrie;
|
zmq::generic_mtrie_t<int> mtrie;
|
||||||
const zmq::generic_mtrie_t<int>::prefix_t add_name_data =
|
const zmq::generic_mtrie_t<int>::prefix_t add_name_data =
|
||||||
reinterpret_cast<zmq::generic_mtrie_t<int>::prefix_t> (add_name);
|
reinterpret_cast<zmq::generic_mtrie_t<int>::prefix_t> (add_name_);
|
||||||
const zmq::generic_mtrie_t<int>::prefix_t rm_name_data =
|
const zmq::generic_mtrie_t<int>::prefix_t rm_name_data =
|
||||||
reinterpret_cast<zmq::generic_mtrie_t<int>::prefix_t> (rm_name);
|
reinterpret_cast<zmq::generic_mtrie_t<int>::prefix_t> (rm_name_);
|
||||||
|
|
||||||
mtrie.add (add_name_data, getlen (add_name_data), &addpipe);
|
mtrie.add (add_name_data, getlen (add_name_data), &addpipe);
|
||||||
|
|
||||||
@@ -209,8 +209,8 @@ void test_add_and_rm_other (const char *add_name, const char *rm_name)
|
|||||||
TEST_ASSERT_EQUAL_INT (1, count);
|
TEST_ASSERT_EQUAL_INT (1, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp (add_name, rm_name,
|
if (strncmp (add_name_, rm_name_,
|
||||||
std::min (strlen (add_name), strlen (rm_name) + 1))
|
std::min (strlen (add_name_), strlen (rm_name_) + 1))
|
||||||
!= 0) {
|
!= 0) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
mtrie.match (rm_name_data, getlen (rm_name_data), mtrie_count, &count);
|
mtrie.match (rm_name_data, getlen (rm_name_data), mtrie_count, &count);
|
||||||
@@ -240,15 +240,15 @@ void test_rm_nonexistent_nonempty_prefixed ()
|
|||||||
test_add_and_rm_other ("foo", "foobar");
|
test_add_and_rm_other ("foo", "foobar");
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_indexed_expect_unique (zmq::generic_mtrie_t<int> &mtrie,
|
void add_indexed_expect_unique (zmq::generic_mtrie_t<int> &mtrie_,
|
||||||
int *pipes,
|
int *pipes_,
|
||||||
const char **names,
|
const char **names_,
|
||||||
size_t i)
|
size_t i_)
|
||||||
{
|
{
|
||||||
const zmq::generic_mtrie_t<int>::prefix_t name_data =
|
const zmq::generic_mtrie_t<int>::prefix_t name_data =
|
||||||
reinterpret_cast<zmq::generic_mtrie_t<int>::prefix_t> (names[i]);
|
reinterpret_cast<zmq::generic_mtrie_t<int>::prefix_t> (names_[i_]);
|
||||||
|
|
||||||
bool res = mtrie.add (name_data, getlen (name_data), &pipes[i]);
|
bool res = mtrie_.add (name_data, getlen (name_data), &pipes_[i_]);
|
||||||
TEST_ASSERT_EQUAL (zmq::generic_mtrie_t<int>::last_value_removed, res);
|
TEST_ASSERT_EQUAL (zmq::generic_mtrie_t<int>::last_value_removed, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,12 +270,12 @@ void test_rm_nonexistent_between ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
void add_entries (zmq::generic_mtrie_t<int> &mtrie,
|
void add_entries (zmq::generic_mtrie_t<int> &mtrie_,
|
||||||
int (&pipes)[N],
|
int (&pipes_)[N],
|
||||||
const char *(&names)[N])
|
const char *(&names_)[N])
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < N; ++i) {
|
for (size_t i = 0; i < N; ++i) {
|
||||||
add_indexed_expect_unique (mtrie, pipes, names, i);
|
add_indexed_expect_unique (mtrie_, pipes_, names_, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,15 +315,15 @@ void test_add_multiple_reverse ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t N> void add_and_rm_entries (const char *(&names)[N])
|
template <size_t N> void add_and_rm_entries (const char *(&names_)[N])
|
||||||
{
|
{
|
||||||
int pipes[N];
|
int pipes[N];
|
||||||
zmq::generic_mtrie_t<int> mtrie;
|
zmq::generic_mtrie_t<int> mtrie;
|
||||||
add_entries (mtrie, pipes, names);
|
add_entries (mtrie, pipes, names_);
|
||||||
|
|
||||||
for (size_t i = 0; i < N; ++i) {
|
for (size_t i = 0; i < N; ++i) {
|
||||||
const zmq::generic_mtrie_t<int>::prefix_t name_data =
|
const zmq::generic_mtrie_t<int>::prefix_t name_data =
|
||||||
reinterpret_cast<zmq::generic_mtrie_t<int>::prefix_t> (names[i]);
|
reinterpret_cast<zmq::generic_mtrie_t<int>::prefix_t> (names_[i]);
|
||||||
|
|
||||||
zmq::generic_mtrie_t<int>::rm_result res =
|
zmq::generic_mtrie_t<int>::rm_result res =
|
||||||
mtrie.rm (name_data, getlen (name_data), &pipes[i]);
|
mtrie.rm (name_data, getlen (name_data), &pipes[i]);
|
||||||
@@ -351,14 +351,14 @@ void check_name (zmq::generic_mtrie_t<int>::prefix_t data_,
|
|||||||
TEST_ASSERT_EQUAL_STRING_LEN (name_, data_, len_);
|
TEST_ASSERT_EQUAL_STRING_LEN (name_, data_, len_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t N> void add_entries_rm_pipes_unique (const char *(&names)[N])
|
template <size_t N> void add_entries_rm_pipes_unique (const char *(&names_)[N])
|
||||||
{
|
{
|
||||||
int pipes[N];
|
int pipes[N];
|
||||||
zmq::generic_mtrie_t<int> mtrie;
|
zmq::generic_mtrie_t<int> mtrie;
|
||||||
add_entries (mtrie, pipes, names);
|
add_entries (mtrie, pipes, names_);
|
||||||
|
|
||||||
for (size_t i = 0; i < N; ++i) {
|
for (size_t i = 0; i < N; ++i) {
|
||||||
mtrie.rm (&pipes[i], check_name, names[i], false);
|
mtrie.rm (&pipes[i], check_name, names_[i], false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,16 +384,16 @@ void check_count (zmq::generic_mtrie_t<int>::prefix_t data_,
|
|||||||
TEST_ASSERT_GREATER_OR_EQUAL (0, *count_);
|
TEST_ASSERT_GREATER_OR_EQUAL (0, *count_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_duplicate_entry (zmq::generic_mtrie_t<int> &mtrie, int (&pipes)[2])
|
void add_duplicate_entry (zmq::generic_mtrie_t<int> &mtrie_, int (&pipes_)[2])
|
||||||
{
|
{
|
||||||
const char *name = "foo";
|
const char *name = "foo";
|
||||||
|
|
||||||
const zmq::generic_mtrie_t<int>::prefix_t name_data =
|
const zmq::generic_mtrie_t<int>::prefix_t name_data =
|
||||||
reinterpret_cast<zmq::generic_mtrie_t<int>::prefix_t> (name);
|
reinterpret_cast<zmq::generic_mtrie_t<int>::prefix_t> (name);
|
||||||
|
|
||||||
bool res = mtrie.add (name_data, getlen (name_data), &pipes[0]);
|
bool res = mtrie_.add (name_data, getlen (name_data), &pipes_[0]);
|
||||||
TEST_ASSERT_TRUE (res);
|
TEST_ASSERT_TRUE (res);
|
||||||
res = mtrie.add (name_data, getlen (name_data), &pipes[1]);
|
res = mtrie_.add (name_data, getlen (name_data), &pipes_[1]);
|
||||||
TEST_ASSERT_FALSE (res);
|
TEST_ASSERT_FALSE (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,16 +57,16 @@ void test_start_empty ()
|
|||||||
struct test_events_t : zmq::i_poll_events
|
struct test_events_t : zmq::i_poll_events
|
||||||
{
|
{
|
||||||
test_events_t (zmq::fd_t fd_, zmq::poller_t &poller_) :
|
test_events_t (zmq::fd_t fd_, zmq::poller_t &poller_) :
|
||||||
fd (fd_),
|
_fd (fd_),
|
||||||
poller (poller_)
|
_poller (poller_)
|
||||||
{
|
{
|
||||||
(void)fd;
|
(void) _fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void in_event ()
|
virtual void in_event ()
|
||||||
{
|
{
|
||||||
poller.rm_fd (handle);
|
_poller.rm_fd (_handle);
|
||||||
handle = (zmq::poller_t::handle_t) NULL;
|
_handle = (zmq::poller_t::handle_t) NULL;
|
||||||
|
|
||||||
// this must only be incremented after rm_fd
|
// this must only be incremented after rm_fd
|
||||||
in_events.add (1);
|
in_events.add (1);
|
||||||
@@ -82,27 +82,27 @@ struct test_events_t : zmq::i_poll_events
|
|||||||
virtual void timer_event (int id_)
|
virtual void timer_event (int id_)
|
||||||
{
|
{
|
||||||
LIBZMQ_UNUSED (id_);
|
LIBZMQ_UNUSED (id_);
|
||||||
poller.rm_fd (handle);
|
_poller.rm_fd (_handle);
|
||||||
handle = (zmq::poller_t::handle_t) NULL;
|
_handle = (zmq::poller_t::handle_t) NULL;
|
||||||
|
|
||||||
// this must only be incremented after rm_fd
|
// this must only be incremented after rm_fd
|
||||||
timer_events.add (1);
|
timer_events.add (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_handle (zmq::poller_t::handle_t handle_) { handle = handle_; }
|
void set_handle (zmq::poller_t::handle_t handle_) { _handle = handle_; }
|
||||||
|
|
||||||
zmq::atomic_counter_t in_events, timer_events;
|
zmq::atomic_counter_t in_events, timer_events;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
zmq::fd_t fd;
|
zmq::fd_t _fd;
|
||||||
zmq::poller_t &poller;
|
zmq::poller_t &_poller;
|
||||||
zmq::poller_t::handle_t handle;
|
zmq::poller_t::handle_t _handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
void wait_in_events (test_events_t &events)
|
void wait_in_events (test_events_t &events_)
|
||||||
{
|
{
|
||||||
void *watch = zmq_stopwatch_start ();
|
void *watch = zmq_stopwatch_start ();
|
||||||
while (events.in_events.get () < 1) {
|
while (events_.in_events.get () < 1) {
|
||||||
#ifdef ZMQ_BUILD_DRAFT
|
#ifdef ZMQ_BUILD_DRAFT
|
||||||
TEST_ASSERT_LESS_OR_EQUAL_MESSAGE (SETTLE_TIME,
|
TEST_ASSERT_LESS_OR_EQUAL_MESSAGE (SETTLE_TIME,
|
||||||
zmq_stopwatch_intermediate (watch),
|
zmq_stopwatch_intermediate (watch),
|
||||||
@@ -112,10 +112,10 @@ void wait_in_events (test_events_t &events)
|
|||||||
zmq_stopwatch_stop (watch);
|
zmq_stopwatch_stop (watch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait_timer_events (test_events_t &events)
|
void wait_timer_events (test_events_t &events_)
|
||||||
{
|
{
|
||||||
void *watch = zmq_stopwatch_start ();
|
void *watch = zmq_stopwatch_start ();
|
||||||
while (events.timer_events.get () < 1) {
|
while (events_.timer_events.get () < 1) {
|
||||||
#ifdef ZMQ_BUILD_DRAFT
|
#ifdef ZMQ_BUILD_DRAFT
|
||||||
TEST_ASSERT_LESS_OR_EQUAL_MESSAGE (SETTLE_TIME,
|
TEST_ASSERT_LESS_OR_EQUAL_MESSAGE (SETTLE_TIME,
|
||||||
zmq_stopwatch_intermediate (watch),
|
zmq_stopwatch_intermediate (watch),
|
||||||
@@ -125,40 +125,40 @@ void wait_timer_events (test_events_t &events)
|
|||||||
zmq_stopwatch_stop (watch);
|
zmq_stopwatch_stop (watch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_nonblocking_fdpair (zmq::fd_t *r, zmq::fd_t *w)
|
void create_nonblocking_fdpair (zmq::fd_t *r_, zmq::fd_t *w_)
|
||||||
{
|
{
|
||||||
int rc = zmq::make_fdpair (r, w);
|
int rc = zmq::make_fdpair (r_, w_);
|
||||||
TEST_ASSERT_EQUAL_INT (0, rc);
|
TEST_ASSERT_EQUAL_INT (0, rc);
|
||||||
TEST_ASSERT_NOT_EQUAL (zmq::retired_fd, *r);
|
TEST_ASSERT_NOT_EQUAL (zmq::retired_fd, *r_);
|
||||||
TEST_ASSERT_NOT_EQUAL (zmq::retired_fd, *w);
|
TEST_ASSERT_NOT_EQUAL (zmq::retired_fd, *w_);
|
||||||
zmq::unblock_socket (*r);
|
zmq::unblock_socket (*r_);
|
||||||
zmq::unblock_socket (*w);
|
zmq::unblock_socket (*w_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_signal (zmq::fd_t w)
|
void send_signal (zmq::fd_t w_)
|
||||||
{
|
{
|
||||||
#if defined ZMQ_HAVE_EVENTFD
|
#if defined ZMQ_HAVE_EVENTFD
|
||||||
const uint64_t inc = 1;
|
const uint64_t inc = 1;
|
||||||
ssize_t sz = write (w, &inc, sizeof (inc));
|
ssize_t sz = write (w_, &inc, sizeof (inc));
|
||||||
assert (sz == sizeof (inc));
|
assert (sz == sizeof (inc));
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
char msg[] = "test";
|
char msg[] = "test";
|
||||||
int rc = send (w, msg, sizeof (msg), 0);
|
int rc = send (w_, msg, sizeof (msg), 0);
|
||||||
assert (rc == sizeof (msg));
|
assert (rc == sizeof (msg));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void close_fdpair (zmq::fd_t w, zmq::fd_t r)
|
void close_fdpair (zmq::fd_t w_, zmq::fd_t r_)
|
||||||
{
|
{
|
||||||
int rc = closesocket (w);
|
int rc = closesocket (w_);
|
||||||
TEST_ASSERT_EQUAL_INT (0, rc);
|
TEST_ASSERT_EQUAL_INT (0, rc);
|
||||||
#if !defined ZMQ_HAVE_EVENTFD
|
#if !defined ZMQ_HAVE_EVENTFD
|
||||||
rc = closesocket (r);
|
rc = closesocket (r_);
|
||||||
TEST_ASSERT_EQUAL_INT (0, rc);
|
TEST_ASSERT_EQUAL_INT (0, rc);
|
||||||
#else
|
#else
|
||||||
LIBZMQ_UNUSED (r);
|
LIBZMQ_UNUSED (r_);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -222,13 +222,13 @@ void test_size ()
|
|||||||
TEST_ASSERT_TRUE (tree.size () == 0);
|
TEST_ASSERT_TRUE (tree.size () == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void return_key (unsigned char *data, size_t size, void *arg)
|
void return_key (unsigned char *data_, size_t size_, void *arg_)
|
||||||
{
|
{
|
||||||
std::vector<std::string> *vec =
|
std::vector<std::string> *vec =
|
||||||
reinterpret_cast<std::vector<std::string> *> (arg);
|
reinterpret_cast<std::vector<std::string> *> (arg_);
|
||||||
std::string key;
|
std::string key;
|
||||||
for (size_t i = 0; i < size; ++i)
|
for (size_t i = 0; i < size_; ++i)
|
||||||
key.push_back (static_cast<char> (data[i]));
|
key.push_back (static_cast<char> (data_[i]));
|
||||||
vec->push_back (key);
|
vec->push_back (key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user