Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
a83c57d0
Commit
a83c57d0
authored
Dec 08, 2019
by
Simon Giesecke
Committed by
Simon Giesecke
Dec 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: identifiers not conformant with naming convention
Solution: fix identifier names
parent
18edd289
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
209 additions
and
209 deletions
+209
-209
ctx.cpp
src/ctx.cpp
+4
-4
radix_tree.cpp
src/radix_tree.cpp
+2
-2
socks_connecter.cpp
src/socks_connecter.cpp
+6
-6
stream_connecter_base.cpp
src/stream_connecter_base.cpp
+4
-4
stream_listener_base.cpp
src/stream_listener_base.cpp
+6
-6
tcp_address.cpp
src/tcp_address.cpp
+12
-12
thread.cpp
src/thread.cpp
+2
-2
tipc_address.cpp
src/tipc_address.cpp
+9
-9
ws_connecter.cpp
src/ws_connecter.cpp
+4
-4
ws_engine.cpp
src/ws_engine.cpp
+26
-26
ws_listener.cpp
src/ws_listener.cpp
+6
-6
zmq.cpp
src/zmq.cpp
+4
-4
zmtp_engine.cpp
src/zmtp_engine.cpp
+4
-4
test_hwm_pubsub.cpp
tests/test_hwm_pubsub.cpp
+7
-7
test_mock_pub_sub.cpp
tests/test_mock_pub_sub.cpp
+2
-2
test_monitor.cpp
tests/test_monitor.cpp
+8
-8
test_proxy_hwm.cpp
tests/test_proxy_hwm.cpp
+14
-14
test_router_notify.cpp
tests/test_router_notify.cpp
+4
-4
test_spec_pushpull.cpp
tests/test_spec_pushpull.cpp
+2
-2
test_spec_rep.cpp
tests/test_spec_rep.cpp
+4
-4
test_spec_router.cpp
tests/test_spec_router.cpp
+4
-4
testutil.cpp
tests/testutil.cpp
+7
-7
testutil_unity.cpp
tests/testutil_unity.cpp
+7
-7
unittest_mtrie.cpp
unittests/unittest_mtrie.cpp
+29
-29
unittest_poller.cpp
unittests/unittest_poller.cpp
+28
-28
unittest_radix_tree.cpp
unittests/unittest_radix_tree.cpp
+4
-4
No files found.
src/ctx.cpp
View file @
a83c57d0
...
...
@@ -385,11 +385,11 @@ int zmq::ctx_t::get (int option_, void *optval_, size_t *optvallen_)
int
zmq
::
ctx_t
::
get
(
int
option_
)
{
int
optval
_
=
0
;
size_t
optvallen
_
=
sizeof
(
int
);
int
optval
=
0
;
size_t
optvallen
=
sizeof
(
int
);
if
(
get
(
option_
,
&
optval
_
,
&
optvallen_
)
==
0
)
return
optval
_
;
if
(
get
(
option_
,
&
optval
,
&
optvallen
)
==
0
)
return
optval
;
errno
=
EINVAL
;
return
-
1
;
...
...
src/radix_tree.cpp
View file @
a83c57d0
...
...
@@ -540,7 +540,7 @@ bool zmq::radix_tree_t::check (const unsigned char *key_, size_t key_size_)
static
void
visit_keys
(
node_t
node_
,
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_
)
{
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
(
*
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
)
func_
(
NULL
,
0
,
arg_
);
// Root node is always empty.
...
...
src/socks_connecter.cpp
View file @
a83c57d0
...
...
@@ -79,12 +79,12 @@ void zmq::socks_connecter_t::set_auth_method_none ()
_auth_password
.
clear
();
}
void
zmq
::
socks_connecter_t
::
set_auth_method_basic
(
const
std
::
string
username
,
const
std
::
string
password
)
void
zmq
::
socks_connecter_t
::
set_auth_method_basic
(
const
std
::
string
username
_
,
const
std
::
string
password
_
)
{
_auth_method
=
socks_basic_auth
;
_auth_username
=
username
;
_auth_password
=
password
;
_auth_username
=
username
_
;
_auth_password
=
password
_
;
}
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
=
rc
|
tune_tcp_keepalives
(
_s
,
options
.
tcp_keepalive
,
options
.
tcp_keepalive_cnt
,
options
.
tcp_keepalive_idle
,
options
.
tcp_keepalive_intvl
);
_s
,
options
.
tcp_keepalive
,
options
.
tcp_keepalive_cnt
,
options
.
tcp_keepalive_idle
,
options
.
tcp_keepalive_intvl
);
if
(
rc
!=
0
)
return
-
1
;
...
...
src/stream_connecter_base.cpp
View file @
a83c57d0
...
...
@@ -169,7 +169,7 @@ void zmq::stream_connecter_base_t::in_event ()
}
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
,
endpoint_type_connect
);
...
...
@@ -177,9 +177,9 @@ void zmq::stream_connecter_base_t::create_engine (
// Create the engine object for this connection.
i_engine
*
engine
;
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
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
);
// Attach the engine to the corresponding session object.
...
...
@@ -188,7 +188,7 @@ void zmq::stream_connecter_base_t::create_engine (
// Shut the connecter down.
terminate
();
_socket
->
event_connected
(
endpoint_pair
,
fd
);
_socket
->
event_connected
(
endpoint_pair
,
fd
_
);
}
void
zmq
::
stream_connecter_base_t
::
timer_event
(
int
id_
)
...
...
src/stream_listener_base.cpp
View file @
a83c57d0
...
...
@@ -97,17 +97,17 @@ int zmq::stream_listener_base_t::close ()
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
(
get_socket_name
(
fd
,
socket_end_local
),
get_socket_name
(
fd
,
socket_end_remote
),
endpoint_type_bind
);
get_socket_name
(
fd
_
,
socket_end_local
),
get_socket_name
(
fd
_
,
socket_end_remote
),
endpoint_type_bind
);
i_engine
*
engine
;
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
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
);
// 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
);
send_attach
(
session
,
engine
,
false
);
_socket
->
event_accepted
(
endpoint_pair
,
fd
);
_socket
->
event_accepted
(
endpoint_pair
,
fd
_
);
}
src/tcp_address.cpp
View file @
a83c57d0
...
...
@@ -113,23 +113,23 @@ int zmq::tcp_address_t::resolve (const char *name_, bool local_, bool ipv6_)
}
template
<
size_t
N1
,
size_t
N2
>
static
std
::
string
make_address_string
(
const
char
*
hbuf
,
uint16_t
port
,
const
char
(
&
ipv6_prefix
)[
N1
],
const
char
(
&
ipv6_suffix
)[
N2
])
static
std
::
string
make_address_string
(
const
char
*
hbuf
_
,
uint16_t
port
_
,
const
char
(
&
ipv6_prefix
_
)[
N1
],
const
char
(
&
ipv6_suffix
_
)[
N2
])
{
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
];
char
*
pos
=
buf
;
memcpy
(
pos
,
ipv6_prefix
,
sizeof
ipv6_prefix
-
1
);
pos
+=
sizeof
ipv6_prefix
-
1
;
const
size_t
hbuf_len
=
strlen
(
hbuf
);
memcpy
(
pos
,
hbuf
,
hbuf_len
);
memcpy
(
pos
,
ipv6_prefix
_
,
sizeof
ipv6_prefix_
-
1
);
pos
+=
sizeof
ipv6_prefix
_
-
1
;
const
size_t
hbuf_len
=
strlen
(
hbuf
_
);
memcpy
(
pos
,
hbuf
_
,
hbuf_len
);
pos
+=
hbuf_len
;
memcpy
(
pos
,
ipv6_suffix
,
sizeof
ipv6_suffix
-
1
);
pos
+=
sizeof
ipv6_suffix
-
1
;
pos
+=
sprintf
(
pos
,
"%d"
,
ntohs
(
port
));
memcpy
(
pos
,
ipv6_suffix
_
,
sizeof
ipv6_suffix_
-
1
);
pos
+=
sizeof
ipv6_suffix
_
-
1
;
pos
+=
sprintf
(
pos
,
"%d"
,
ntohs
(
port
_
));
return
std
::
string
(
buf
,
pos
-
buf
);
}
...
...
src/thread.cpp
View file @
a83c57d0
...
...
@@ -277,10 +277,10 @@ bool zmq::thread_t::is_current_thread () const
}
void
zmq
::
thread_t
::
setSchedulingParameters
(
int
priority_
,
int
scheduling
P
olicy_
,
const
std
::
set
<
int
>
&
affinity_cpus_
)
int
priority_
,
int
scheduling
_p
olicy_
,
const
std
::
set
<
int
>
&
affinity_cpus_
)
{
_thread_priority
=
priority_
;
_thread_sched_policy
=
scheduling
P
olicy_
;
_thread_sched_policy
=
scheduling
_p
olicy_
;
_thread_affinity_cpus
=
affinity_cpus_
;
}
...
...
src/tipc_address.cpp
View file @
a83c57d0
...
...
@@ -44,13 +44,13 @@ zmq::tipc_address_t::tipc_address_t ()
_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
);
if
(
sa
->
sa_family
==
AF_TIPC
)
memcpy
(
&
address
,
sa
,
sa_len
);
if
(
sa
_
->
sa_family
==
AF_TIPC
)
memcpy
(
&
address
,
sa
_
,
sa_len_
);
_random
=
false
;
}
...
...
@@ -70,7 +70,7 @@ bool zmq::tipc_address_t::is_service () const
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
lower
=
0
;
...
...
@@ -82,7 +82,7 @@ int zmq::tipc_address_t::resolve (const char *name)
int
res
;
if
(
strncmp
(
name
,
"<*>"
,
3
)
==
0
)
{
if
(
strncmp
(
name
_
,
"<*>"
,
3
)
==
0
)
{
set_random
();
address
.
family
=
AF_TIPC
;
address
.
addrtype
=
TIPC_ADDR_ID
;
...
...
@@ -92,9 +92,9 @@ int zmq::tipc_address_t::resolve (const char *name)
return
0
;
}
res
=
sscanf
(
name
,
"{%u,%u,%u}"
,
&
type
,
&
lower
,
&
upper
);
res
=
sscanf
(
name
_
,
"{%u,%u,%u}"
,
&
type
,
&
lower
,
&
upper
);
/* Fetch optional domain suffix. */
if
((
domain
=
strchr
(
name
,
'@'
)))
{
if
((
domain
=
strchr
(
name
_
,
'@'
)))
{
if
(
sscanf
(
domain
,
"@%u.%u.%u%c"
,
&
z
,
&
c
,
&
n
,
&
eof
)
!=
3
)
return
EINVAL
;
}
...
...
@@ -117,7 +117,7 @@ int zmq::tipc_address_t::resolve (const char *name)
address
.
scope
=
0
;
return
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
)
{
address
.
family
=
AF_TIPC
;
address
.
addrtype
=
TIPC_ADDR_ID
;
...
...
src/ws_connecter.cpp
View file @
a83c57d0
...
...
@@ -270,7 +270,7 @@ bool zmq::ws_connecter_t::tune_socket (const fd_t fd_)
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
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
)
#ifdef ZMQ_HAVE_WSS
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
);
#else
assert
(
false
);
#endif
else
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
);
// 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.
terminate
();
_socket
->
event_connected
(
endpoint_pair
,
fd
);
_socket
->
event_connected
(
endpoint_pair
,
fd
_
);
}
src/ws_engine.cpp
View file @
a83c57d0
...
...
@@ -83,10 +83,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif
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
,
unsigned
char
output
[
SHA_DIGEST_LENGTH
]);
static
void
compute_accept_key
(
char
*
key
_
,
unsigned
char
output
_
[
SHA_DIGEST_LENGTH
]);
zmq
::
ws_engine_t
::
ws_engine_t
(
fd_t
fd_
,
const
options_t
&
options_
,
...
...
@@ -196,22 +196,22 @@ int zmq::ws_engine_t::process_routing_id_msg (msg_t *msg_)
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
*
)
>
(
&
ws_engine_t
::
routing_id_msg
);
_process_msg
=
static_cast
<
int
(
stream_engine_base_t
::*
)
(
msg_t
*
)
>
(
&
ws_engine_t
::
process_routing_id_msg
);
return
true
;
}
else
if
(
_options
.
mechanism
==
ZMQ_NULL
&&
strcmp
(
"ZWS2.0/NULL"
,
protocol
)
==
0
)
{
&&
strcmp
(
"ZWS2.0/NULL"
,
protocol
_
)
==
0
)
{
_mechanism
=
new
(
std
::
nothrow
)
null_mechanism_t
(
session
(),
_peer_address
,
_options
);
alloc_assert
(
_mechanism
);
return
true
;
}
else
if
(
_options
.
mechanism
==
ZMQ_PLAIN
&&
strcmp
(
"ZWS2.0/PLAIN"
,
protocol
)
==
0
)
{
&&
strcmp
(
"ZWS2.0/PLAIN"
,
protocol
_
)
==
0
)
{
if
(
_options
.
as_server
)
_mechanism
=
new
(
std
::
nothrow
)
plain_server_t
(
session
(),
_peer_address
,
_options
);
...
...
@@ -223,7 +223,7 @@ bool zmq::ws_engine_t::select_protocol (char *protocol)
}
#ifdef ZMQ_HAVE_CURVE
else
if
(
_options
.
mechanism
==
ZMQ_CURVE
&&
strcmp
(
"ZWS2.0/CURVE"
,
protocol
)
==
0
)
{
&&
strcmp
(
"ZWS2.0/CURVE"
,
protocol
_
)
==
0
)
{
if
(
_options
.
as_server
)
_mechanism
=
new
(
std
::
nothrow
)
curve_server_t
(
session
(),
_peer_address
,
_options
);
...
...
@@ -877,7 +877,7 @@ bool zmq::ws_engine_t::client_handshake ()
}
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
]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
...
...
@@ -886,36 +886,36 @@ encode_base64 (const unsigned char *in, int in_len, char *out, int out_len)
uint32_t
v
;
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
;
ch
=
in
[
ii
];
ch
=
in
_
[
ii
];
v
=
(
v
<<
8
)
|
ch
;
rem
+=
8
;
while
(
rem
>=
6
)
{
rem
-=
6
;
if
(
io
>=
out_len
)
if
(
io
>=
out_len
_
)
return
-
1
;
/* truncation is failure */
out
[
io
++
]
=
base64enc_tab
[(
v
>>
rem
)
&
63
];
out
_
[
io
++
]
=
base64enc_tab
[(
v
>>
rem
)
&
63
];
}
}
if
(
rem
)
{
v
<<=
(
6
-
rem
);
if
(
io
>=
out_len
)
if
(
io
>=
out_len
_
)
return
-
1
;
/* truncation is failure */
out
[
io
++
]
=
base64enc_tab
[
v
&
63
];
out
_
[
io
++
]
=
base64enc_tab
[
v
&
63
];
}
while
(
io
&
3
)
{
if
(
io
>=
out_len
)
if
(
io
>=
out_len
_
)
return
-
1
;
/* truncation is failure */
out
[
io
++
]
=
'='
;
out
_
[
io
++
]
=
'='
;
}
if
(
io
>=
out_len
)
if
(
io
>=
out_len
_
)
return
-
1
;
/* no room for null terminator */
out
[
io
]
=
0
;
out
_
[
io
]
=
0
;
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"
;
#ifdef ZMQ_USE_NSS
...
...
@@ -925,24 +925,24 @@ static void compute_accept_key (char *key, unsigned char *hash)
assert
(
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
,
(
unsigned
int
)
strlen
(
magic_string
));
HASH_End
(
ctx
,
hash
,
&
len
,
SHA_DIGEST_LENGTH
);
HASH_End
(
ctx
,
hash
_
,
&
len
,
SHA_DIGEST_LENGTH
);
HASH_Destroy
(
ctx
);
#elif defined ZMQ_USE_BUILTIN_SHA1
sha1_ctxt
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_Final
(
hash
,
&
ctx
);
SHA1_Final
(
hash
_
,
&
ctx
);
#elif defined ZMQ_USE_GNUTLS
gnutls_hash_hd_t
hd
;
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_deinit
(
hd
,
hash
);
gnutls_hash_deinit
(
hd
,
hash
_
);
#else
#error "No sha1 implementation set"
#endif
...
...
src/ws_listener.cpp
View file @
a83c57d0
...
...
@@ -285,23 +285,23 @@ zmq::fd_t zmq::ws_listener_t::accept ()
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
(
get_socket_name
(
fd
,
socket_end_local
),
get_socket_name
(
fd
,
socket_end_remote
),
endpoint_type_bind
);
get_socket_name
(
fd
_
,
socket_end_local
),
get_socket_name
(
fd
_
,
socket_end_remote
),
endpoint_type_bind
);
i_engine
*
engine
=
NULL
;
if
(
_wss
)
#ifdef ZMQ_HAVE_WSS
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
assert
(
false
);
#endif
else
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
);
// 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
);
send_attach
(
session
,
engine
,
false
);
_socket
->
event_accepted
(
endpoint_pair
,
fd
);
_socket
->
event_accepted
(
endpoint_pair
,
fd
_
);
}
src/zmq.cpp
View file @
a83c57d0
...
...
@@ -194,10 +194,10 @@ int zmq_ctx_set_ext (void *ctx_,
int
zmq_ctx_get
(
void
*
ctx_
,
int
option_
)
{
int
optval
_
=
0
;
size_t
optvallen
_
=
sizeof
(
int
);
if
(
zmq_ctx_get_ext
(
ctx_
,
option_
,
&
optval
_
,
&
optvallen_
)
==
0
)
{
return
optval
_
;
int
optval
=
0
;
size_t
optvallen
=
sizeof
(
int
);
if
(
zmq_ctx_get_ext
(
ctx_
,
option_
,
&
optval
,
&
optvallen
)
==
0
)
{
return
optval
;
}
errno
=
EFAULT
;
...
...
src/zmtp_engine.cpp
View file @
a83c57d0
...
...
@@ -229,14 +229,14 @@ void zmq::zmtp_engine_t::receive_greeting_versioned ()
}
zmq
::
zmtp_engine_t
::
handshake_fun_t
zmq
::
zmtp_engine_t
::
select_handshake_fun
(
bool
unversioned
,
unsigned
char
revision
)
zmq
::
zmtp_engine_t
::
select_handshake_fun
(
bool
unversioned
_
,
unsigned
char
revision
_
)
{
// Is the peer using ZMTP/1.0 with no revision number?
if
(
unversioned
)
{
if
(
unversioned
_
)
{
return
&
zmtp_engine_t
::
handshake_v1_0_unversioned
;
}
switch
(
revision
)
{
switch
(
revision
_
)
{
case
ZMTP_1_0
:
return
&
zmtp_engine_t
::
handshake_v1_0
;
case
ZMTP_2_0
:
...
...
tests/test_hwm_pubsub.cpp
View file @
a83c57d0
...
...
@@ -38,13 +38,13 @@
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
];
// Set up and bind XPUB socket
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
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
;
}
int
receive
(
void
*
socket_
,
int
*
is_termination
)
int
receive
(
void
*
socket_
,
int
*
is_termination
_
)
{
int
recv_count
=
0
;
*
is_termination
=
0
;
*
is_termination
_
=
0
;
// Now receive all sent messages
char
buffer
[
255
];
...
...
@@ -98,7 +98,7 @@ int receive (void *socket_, int *is_termination)
++
recv_count
;
if
(
len
==
3
&&
strncmp
(
buffer
,
"end"
,
len
)
==
0
)
{
*
is_termination
=
1
;
*
is_termination
_
=
1
;
return
recv_count
;
}
}
...
...
@@ -106,13 +106,13 @@ int receive (void *socket_, int *is_termination)
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
];
// Set up bind socket
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
void
*
sub_socket
=
test_context_socket
(
ZMQ_SUB
);
...
...
tests/test_mock_pub_sub.cpp
View file @
a83c57d0
...
...
@@ -136,7 +136,7 @@ static void prep_server_socket (void **server_out_,
*
mon_out_
=
server_mon
;
}
static
void
test_mock_sub
(
bool
sub_command
)
static
void
test_mock_sub
(
bool
sub_command
_
)
{
int
rc
;
char
my_endpoint
[
MAX_SOCKET_STRING
];
...
...
@@ -167,7 +167,7 @@ static void test_mock_sub (bool sub_command)
rc
=
get_monitor_event
(
server_mon
);
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'
,
'C'
,
'R'
,
'I'
,
'B'
,
'E'
,
'A'
};
rc
=
...
...
tests/test_monitor.cpp
View file @
a83c57d0
...
...
@@ -196,12 +196,12 @@ void test_monitor_versioned_basic (bind_function_t bind_function_,
// Now do a basic ping test
bind_function_
(
server
,
server_endpoint
,
sizeof
server_endpoint
);
int
ipv6
_
;
size_t
ipv6_size
_
=
sizeof
(
ipv6_
);
int
ipv6
;
size_t
ipv6_size
=
sizeof
(
ipv6
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_getsockopt
(
server
,
ZMQ_IPV6
,
&
ipv6
_
,
&
ipv6_size_
));
zmq_getsockopt
(
server
,
ZMQ_IPV6
,
&
ipv6
,
&
ipv6_size
));
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
));
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
)));
bind_function_
(
push
,
server_endpoint
,
sizeof
(
server_endpoint
));
int
ipv6
_
;
size_t
ipv6_size
_
=
sizeof
(
ipv6_
);
int
ipv6
;
size_t
ipv6_size
=
sizeof
(
ipv6
);
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
)
{
pulls
[
i
]
=
test_context_socket
(
ZMQ_PULL
);
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
;
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_setsockopt
(
pulls
[
i
],
ZMQ_RCVTIMEO
,
&
timeout_ms
,
sizeof
(
timeout_ms
)));
...
...
tests/test_proxy_hwm.cpp
View file @
a83c57d0
...
...
@@ -71,19 +71,19 @@ typedef struct
void
*
subscriber_received_all
;
}
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
(
zmq_setsockopt
(
skt
,
ZMQ_SNDHWM
,
&
send_hwm_
,
sizeof
(
send_hwm_
)));
zmq_setsockopt
(
skt
_
,
ZMQ_SNDHWM
,
&
send_hwm
,
sizeof
(
send_hwm
)));
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
);
assert
(
pubsocket
);
...
...
@@ -136,9 +136,9 @@ static void publisher_thread_main (void *pvoid)
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
);
assert
(
subsocket
);
...
...
@@ -190,7 +190,7 @@ static void subscriber_thread_main (void *pvoid)
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
;
...
...
@@ -205,7 +205,7 @@ bool recv_stat (void *sock_, bool last_, uint64_t *res)
}
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
);
assert
(
rc
==
0
);
...
...
@@ -264,9 +264,9 @@ bool check_proxy_stats (void *control_proxy_)
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
...
...
@@ -316,9 +316,9 @@ static void proxy_stats_asker_thread_main (void *pvoid)
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
;
...
...
tests/test_router_notify.cpp
View file @
a83c57d0
...
...
@@ -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
);
int
opt_more
;
...
...
@@ -148,7 +148,7 @@ void test_router_notify_helper (int opt_notify)
// valid values
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
);
...
...
@@ -162,7 +162,7 @@ void test_router_notify_helper (int opt_notify)
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_connect
(
dealer
,
connect_address
));
// connection notification msg
if
(
opt_notify
&
ZMQ_NOTIFY_CONNECT
)
{
if
(
opt_notify
_
&
ZMQ_NOTIFY_CONNECT
)
{
// routing-id only message of the connect
recv_string_expect_success
(
router
,
dealer_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
);
// connection notification msg
if
(
opt_notify
&
ZMQ_NOTIFY_DISCONNECT
)
{
if
(
opt_notify
_
&
ZMQ_NOTIFY_DISCONNECT
)
{
// routing-id only message of the connect
recv_string_expect_success
(
router
,
dealer_routing_id
,
0
);
// 1st part: routing-id
...
...
tests/test_spec_pushpull.cpp
View file @
a83c57d0
...
...
@@ -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.
void
test_push_multipart_atomic_drop
(
const
char
*
bind_address_
,
const
bool
block
)
const
bool
block
_
)
{
int
linger
=
0
;
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
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_msg_init_size
(
&
msg_data
,
len
));
memset
(
zmq_msg_data
(
&
msg_data
),
'c'
,
len
);
if
(
block
)
{
if
(
block
_
)
{
TEST_ASSERT_EQUAL_INT
(
len
,
zmq_msg_send
(
&
msg_data
,
push
,
ZMQ_SNDMORE
));
}
else
{
...
...
tests/test_spec_rep.cpp
View file @
a83c57d0
...
...
@@ -36,7 +36,7 @@ SETUP_TEARDOWN_TESTCONTEXT
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
);
...
...
@@ -44,7 +44,7 @@ void test_fair_queue_in (const char *bind_address)
TEST_ASSERT_SUCCESS_ERRNO
(
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
;
TEST_ASSERT_SUCCESS_ERRNO
(
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
]);
}
void
test_envelope
(
const
char
*
bind_address
)
void
test_envelope
(
const
char
*
bind_address
_
)
{
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
;
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_getsockopt
(
rep
,
ZMQ_LAST_ENDPOINT
,
connect_address
,
&
len
));
...
...
tests/test_spec_router.cpp
View file @
a83c57d0
...
...
@@ -37,7 +37,7 @@ SETUP_TEARDOWN_TESTCONTEXT
// SHALL receive incoming messages from its peers using a fair-queuing
// 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
];
void
*
receiver
=
test_context_socket
(
ZMQ_ROUTER
);
...
...
@@ -46,7 +46,7 @@ void test_fair_queue_in (const char *bind_address)
TEST_ASSERT_SUCCESS_ERRNO
(
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
;
TEST_ASSERT_SUCCESS_ERRNO
(
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
// disconnects, the ROUTER socket SHALL destroy its double queue and SHALL
// 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
);
...
...
@@ -124,7 +124,7 @@ void test_destroy_queue_on_disconnect (const char *bind_address)
TEST_ASSERT_SUCCESS_ERRNO
(
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
;
char
connect_address
[
MAX_SOCKET_STRING
];
TEST_ASSERT_SUCCESS_ERRNO
(
...
...
tests/testutil.cpp
View file @
a83c57d0
...
...
@@ -342,7 +342,7 @@ int test_inet_pton (int af_, const char *src_, void *dst_)
#endif
}
sockaddr_in
bind_bsd_socket
(
int
socket
)
sockaddr_in
bind_bsd_socket
(
int
socket
_
)
{
struct
sockaddr_in
saddr
;
memset
(
&
saddr
,
0
,
sizeof
(
saddr
));
...
...
@@ -355,23 +355,23 @@ sockaddr_in bind_bsd_socket (int socket)
#endif
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)
socklen_t
saddr_len
=
sizeof
(
saddr
);
TEST_ASSERT_SUCCESS_RAW_ERRNO
(
getsockname
(
socket
,
(
struct
sockaddr
*
)
&
saddr
,
&
saddr_len
));
getsockname
(
socket
_
,
(
struct
sockaddr
*
)
&
saddr
,
&
saddr_len
));
#endif
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
;
}
tests/testutil_unity.cpp
View file @
a83c57d0
...
...
@@ -40,7 +40,7 @@
int
test_assert_success_message_errno_helper
(
int
rc_
,
const
char
*
msg_
,
const
char
*
expr_
,
int
line
)
int
line
_
)
{
if
(
rc_
==
-
1
)
{
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_
,
msg_
?
" (additional info: "
:
""
,
msg_
?
msg_
:
""
,
msg_
?
")"
:
""
,
zmq_errno
(),
zmq_strerror
(
zmq_errno
()));
UNITY_TEST_FAIL
(
line
,
buffer
);
UNITY_TEST_FAIL
(
line
_
,
buffer
);
}
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_
,
const
char
*
msg_
,
const
char
*
expr_
,
int
line
)
int
line
_
)
{
if
(
rc_
==
-
1
)
{
#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"
,
expr_
,
msg_
?
" (additional info: "
:
""
,
msg_
?
msg_
:
""
,
msg_
?
")"
:
""
,
current_errno
);
UNITY_TEST_FAIL
(
line
,
buffer
);
UNITY_TEST_FAIL
(
line
_
,
buffer
);
}
return
rc_
;
}
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
];
buffer
[
sizeof
(
buffer
)
-
1
]
=
...
...
@@ -90,7 +90,7 @@ int test_assert_failure_message_raw_errno_helper (
"errno = %i, actual return value = %i"
,
expr_
,
msg_
?
" (additional info: "
:
""
,
msg_
?
msg_
:
""
,
msg_
?
")"
:
""
,
expected_errno_
,
rc_
);
UNITY_TEST_FAIL
(
line
,
buffer
);
UNITY_TEST_FAIL
(
line
_
,
buffer
);
}
else
{
#if defined ZMQ_HAVE_WINDOWS
int
current_errno
=
WSAGetLastError
();
...
...
@@ -104,7 +104,7 @@ int test_assert_failure_message_raw_errno_helper (
expr_
,
msg_
?
" (additional info: "
:
""
,
msg_
?
msg_
:
""
,
msg_
?
")"
:
""
,
expected_errno_
,
current_errno
);
UNITY_TEST_FAIL
(
line
,
buffer
);
UNITY_TEST_FAIL
(
line
_
,
buffer
);
}
}
return
rc_
;
...
...
unittests/unittest_mtrie.cpp
View file @
a83c57d0
...
...
@@ -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
()
...
...
@@ -44,10 +44,10 @@ void test_create ()
zmq
::
generic_mtrie_t
<
int
>
mtrie
;
}
void
mtrie_count
(
int
*
pipe
,
int
*
count
)
void
mtrie_count
(
int
*
pipe
_
,
int
*
count_
)
{
LIBZMQ_UNUSED
(
pipe
);
++*
count
;
LIBZMQ_UNUSED
(
pipe
_
);
++*
count
_
;
}
void
test_check_empty_match_nonempty_data
()
...
...
@@ -187,14 +187,14 @@ void test_rm_nonexistent_empty ()
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
;
zmq
::
generic_mtrie_t
<
int
>
mtrie
;
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
=
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
);
...
...
@@ -209,8 +209,8 @@ void test_add_and_rm_other (const char *add_name, const char *rm_name)
TEST_ASSERT_EQUAL_INT
(
1
,
count
);
}
if
(
strncmp
(
add_name
,
rm_name
,
std
::
min
(
strlen
(
add_name
),
strlen
(
rm_name
)
+
1
))
if
(
strncmp
(
add_name
_
,
rm_name_
,
std
::
min
(
strlen
(
add_name
_
),
strlen
(
rm_name_
)
+
1
))
!=
0
)
{
int
count
=
0
;
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"
);
}
void
add_indexed_expect_unique
(
zmq
::
generic_mtrie_t
<
int
>
&
mtrie
,
int
*
pipes
,
const
char
**
names
,
size_t
i
)
void
add_indexed_expect_unique
(
zmq
::
generic_mtrie_t
<
int
>
&
mtrie
_
,
int
*
pipes
_
,
const
char
**
names
_
,
size_t
i
_
)
{
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
);
}
...
...
@@ -270,12 +270,12 @@ void test_rm_nonexistent_between ()
}
template
<
size_t
N
>
void
add_entries
(
zmq
::
generic_mtrie_t
<
int
>
&
mtrie
,
int
(
&
pipes
)[
N
],
const
char
*
(
&
names
)[
N
])
void
add_entries
(
zmq
::
generic_mtrie_t
<
int
>
&
mtrie
_
,
int
(
&
pipes
_
)[
N
],
const
char
*
(
&
names
_
)[
N
])
{
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
];
zmq
::
generic_mtrie_t
<
int
>
mtrie
;
add_entries
(
mtrie
,
pipes
,
names
);
add_entries
(
mtrie
,
pipes
,
names
_
);
for
(
size_t
i
=
0
;
i
<
N
;
++
i
)
{
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
=
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_
);
}
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
];
zmq
::
generic_mtrie_t
<
int
>
mtrie
;
add_entries
(
mtrie
,
pipes
,
names
);
add_entries
(
mtrie
,
pipes
,
names
_
);
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_
);
}
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
zmq
::
generic_mtrie_t
<
int
>::
prefix_t
name_data
=
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
);
res
=
mtrie
.
add
(
name_data
,
getlen
(
name_data
),
&
pipes
[
1
]);
res
=
mtrie
_
.
add
(
name_data
,
getlen
(
name_data
),
&
pipes_
[
1
]);
TEST_ASSERT_FALSE
(
res
);
}
...
...
unittests/unittest_poller.cpp
View file @
a83c57d0
...
...
@@ -57,16 +57,16 @@ void test_start_empty ()
struct
test_events_t
:
zmq
::
i_poll_events
{
test_events_t
(
zmq
::
fd_t
fd_
,
zmq
::
poller_t
&
poller_
)
:
fd
(
fd_
),
poller
(
poller_
)
_
fd
(
fd_
),
_
poller
(
poller_
)
{
(
void
)
fd
;
(
void
)
_
fd
;
}
virtual
void
in_event
()
{
poller
.
rm_fd
(
handle
);
handle
=
(
zmq
::
poller_t
::
handle_t
)
NULL
;
_poller
.
rm_fd
(
_
handle
);
_
handle
=
(
zmq
::
poller_t
::
handle_t
)
NULL
;
// this must only be incremented after rm_fd
in_events
.
add
(
1
);
...
...
@@ -82,27 +82,27 @@ struct test_events_t : zmq::i_poll_events
virtual
void
timer_event
(
int
id_
)
{
LIBZMQ_UNUSED
(
id_
);
poller
.
rm_fd
(
handle
);
handle
=
(
zmq
::
poller_t
::
handle_t
)
NULL
;
_poller
.
rm_fd
(
_
handle
);
_
handle
=
(
zmq
::
poller_t
::
handle_t
)
NULL
;
// this must only be incremented after rm_fd
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
;
private
:
zmq
::
fd_t
fd
;
zmq
::
poller_t
&
poller
;
zmq
::
poller_t
::
handle_t
handle
;
zmq
::
fd_t
_
fd
;
zmq
::
poller_t
&
_
poller
;
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
();
while
(
events
.
in_events
.
get
()
<
1
)
{
while
(
events
_
.
in_events
.
get
()
<
1
)
{
#ifdef ZMQ_BUILD_DRAFT
TEST_ASSERT_LESS_OR_EQUAL_MESSAGE
(
SETTLE_TIME
,
zmq_stopwatch_intermediate
(
watch
),
...
...
@@ -112,10 +112,10 @@ void wait_in_events (test_events_t &events)
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
();
while
(
events
.
timer_events
.
get
()
<
1
)
{
while
(
events
_
.
timer_events
.
get
()
<
1
)
{
#ifdef ZMQ_BUILD_DRAFT
TEST_ASSERT_LESS_OR_EQUAL_MESSAGE
(
SETTLE_TIME
,
zmq_stopwatch_intermediate
(
watch
),
...
...
@@ -125,40 +125,40 @@ void wait_timer_events (test_events_t &events)
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_NOT_EQUAL
(
zmq
::
retired_fd
,
*
r
);
TEST_ASSERT_NOT_EQUAL
(
zmq
::
retired_fd
,
*
w
);
zmq
::
unblock_socket
(
*
r
);
zmq
::
unblock_socket
(
*
w
);
TEST_ASSERT_NOT_EQUAL
(
zmq
::
retired_fd
,
*
r
_
);
TEST_ASSERT_NOT_EQUAL
(
zmq
::
retired_fd
,
*
w
_
);
zmq
::
unblock_socket
(
*
r
_
);
zmq
::
unblock_socket
(
*
w
_
);
}
void
send_signal
(
zmq
::
fd_t
w
)
void
send_signal
(
zmq
::
fd_t
w
_
)
{
#if defined ZMQ_HAVE_EVENTFD
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
));
#else
{
char
msg
[]
=
"test"
;
int
rc
=
send
(
w
,
msg
,
sizeof
(
msg
),
0
);
int
rc
=
send
(
w
_
,
msg
,
sizeof
(
msg
),
0
);
assert
(
rc
==
sizeof
(
msg
));
}
#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
);
#if !defined ZMQ_HAVE_EVENTFD
rc
=
closesocket
(
r
);
rc
=
closesocket
(
r
_
);
TEST_ASSERT_EQUAL_INT
(
0
,
rc
);
#else
LIBZMQ_UNUSED
(
r
);
LIBZMQ_UNUSED
(
r
_
);
#endif
}
...
...
unittests/unittest_radix_tree.cpp
View file @
a83c57d0
...
...
@@ -222,13 +222,13 @@ void test_size ()
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
=
reinterpret_cast
<
std
::
vector
<
std
::
string
>
*>
(
arg
);
reinterpret_cast
<
std
::
vector
<
std
::
string
>
*>
(
arg
_
);
std
::
string
key
;
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
key
.
push_back
(
static_cast
<
char
>
(
data
[
i
]));
for
(
size_t
i
=
0
;
i
<
size
_
;
++
i
)
key
.
push_back
(
static_cast
<
char
>
(
data
_
[
i
]));
vec
->
push_back
(
key
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment