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
24b79c7e
Commit
24b79c7e
authored
May 28, 2012
by
Martin Hurton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer errno_assert/alloc_assert to zmq_assert
parent
01396768
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
39 additions
and
38 deletions
+39
-38
ctx.cpp
src/ctx.cpp
+1
-1
dealer.cpp
src/dealer.cpp
+1
-1
dist.cpp
src/dist.cpp
+1
-1
lb.cpp
src/lb.cpp
+1
-1
mtrie.cpp
src/mtrie.cpp
+8
-8
pgm_sender.cpp
src/pgm_sender.cpp
+1
-1
session_base.cpp
src/session_base.cpp
+4
-3
signaler.cpp
src/signaler.cpp
+2
-2
socket_base.cpp
src/socket_base.cpp
+5
-5
tcp_address.cpp
src/tcp_address.cpp
+6
-6
trie.cpp
src/trie.cpp
+5
-5
xsub.cpp
src/xsub.cpp
+4
-4
No files found.
src/ctx.cpp
View file @
24b79c7e
...
@@ -113,7 +113,7 @@ int zmq::ctx_t::terminate ()
...
@@ -113,7 +113,7 @@ int zmq::ctx_t::terminate ()
int
rc
=
term_mailbox
.
recv
(
&
cmd
,
-
1
);
int
rc
=
term_mailbox
.
recv
(
&
cmd
,
-
1
);
if
(
rc
==
-
1
&&
errno
==
EINTR
)
if
(
rc
==
-
1
&&
errno
==
EINTR
)
return
-
1
;
return
-
1
;
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
zmq_assert
(
cmd
.
type
==
command_t
::
done
);
zmq_assert
(
cmd
.
type
==
command_t
::
done
);
slot_sync
.
lock
();
slot_sync
.
lock
();
zmq_assert
(
sockets
.
empty
());
zmq_assert
(
sockets
.
empty
());
...
...
src/dealer.cpp
View file @
24b79c7e
...
@@ -89,7 +89,7 @@ bool zmq::dealer_t::xhas_in ()
...
@@ -89,7 +89,7 @@ bool zmq::dealer_t::xhas_in ()
int
rc
=
dealer_t
::
xrecv
(
&
prefetched_msg
,
ZMQ_DONTWAIT
);
int
rc
=
dealer_t
::
xrecv
(
&
prefetched_msg
,
ZMQ_DONTWAIT
);
if
(
rc
!=
0
&&
errno
==
EAGAIN
)
if
(
rc
!=
0
&&
errno
==
EAGAIN
)
return
false
;
return
false
;
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
prefetched
=
true
;
prefetched
=
true
;
return
true
;
return
true
;
}
}
...
...
src/dist.cpp
View file @
24b79c7e
...
@@ -133,7 +133,7 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_)
...
@@ -133,7 +133,7 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_)
int
rc
=
msg_
->
close
();
int
rc
=
msg_
->
close
();
errno_assert
(
rc
==
0
);
errno_assert
(
rc
==
0
);
rc
=
msg_
->
init
();
rc
=
msg_
->
init
();
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
return
;
return
;
}
}
...
...
src/lb.cpp
View file @
24b79c7e
...
@@ -84,7 +84,7 @@ int zmq::lb_t::send (msg_t *msg_, int flags_)
...
@@ -84,7 +84,7 @@ int zmq::lb_t::send (msg_t *msg_, int flags_)
int
rc
=
msg_
->
close
();
int
rc
=
msg_
->
close
();
errno_assert
(
rc
==
0
);
errno_assert
(
rc
==
0
);
rc
=
msg_
->
init
();
rc
=
msg_
->
init
();
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
return
0
;
return
0
;
}
}
...
...
src/mtrie.cpp
View file @
24b79c7e
...
@@ -94,7 +94,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
...
@@ -94,7 +94,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
count
=
(
min
<
c
?
c
-
min
:
min
-
c
)
+
1
;
count
=
(
min
<
c
?
c
-
min
:
min
-
c
)
+
1
;
next
.
table
=
(
mtrie_t
**
)
next
.
table
=
(
mtrie_t
**
)
malloc
(
sizeof
(
mtrie_t
*
)
*
count
);
malloc
(
sizeof
(
mtrie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
for
(
unsigned
short
i
=
0
;
i
!=
count
;
++
i
)
for
(
unsigned
short
i
=
0
;
i
!=
count
;
++
i
)
next
.
table
[
i
]
=
0
;
next
.
table
[
i
]
=
0
;
min
=
std
::
min
(
min
,
c
);
min
=
std
::
min
(
min
,
c
);
...
@@ -107,7 +107,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
...
@@ -107,7 +107,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
count
=
c
-
min
+
1
;
count
=
c
-
min
+
1
;
next
.
table
=
(
mtrie_t
**
)
realloc
((
void
*
)
next
.
table
,
next
.
table
=
(
mtrie_t
**
)
realloc
((
void
*
)
next
.
table
,
sizeof
(
mtrie_t
*
)
*
count
);
sizeof
(
mtrie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
for
(
unsigned
short
i
=
old_count
;
i
!=
count
;
i
++
)
for
(
unsigned
short
i
=
old_count
;
i
!=
count
;
i
++
)
next
.
table
[
i
]
=
NULL
;
next
.
table
[
i
]
=
NULL
;
}
}
...
@@ -118,7 +118,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
...
@@ -118,7 +118,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
count
=
(
min
+
old_count
)
-
c
;
count
=
(
min
+
old_count
)
-
c
;
next
.
table
=
(
mtrie_t
**
)
realloc
((
void
*
)
next
.
table
,
next
.
table
=
(
mtrie_t
**
)
realloc
((
void
*
)
next
.
table
,
sizeof
(
mtrie_t
*
)
*
count
);
sizeof
(
mtrie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
memmove
(
next
.
table
+
min
-
c
,
next
.
table
,
memmove
(
next
.
table
+
min
-
c
,
next
.
table
,
old_count
*
sizeof
(
mtrie_t
*
));
old_count
*
sizeof
(
mtrie_t
*
));
for
(
unsigned
short
i
=
0
;
i
!=
min
-
c
;
i
++
)
for
(
unsigned
short
i
=
0
;
i
!=
min
-
c
;
i
++
)
...
@@ -132,7 +132,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
...
@@ -132,7 +132,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
if
(
!
next
.
node
)
{
if
(
!
next
.
node
)
{
next
.
node
=
new
(
std
::
nothrow
)
mtrie_t
;
next
.
node
=
new
(
std
::
nothrow
)
mtrie_t
;
++
live_nodes
;
++
live_nodes
;
zmq
_assert
(
next
.
node
);
alloc
_assert
(
next
.
node
);
}
}
return
next
.
node
->
add_helper
(
prefix_
+
1
,
size_
-
1
,
pipe_
);
return
next
.
node
->
add_helper
(
prefix_
+
1
,
size_
-
1
,
pipe_
);
}
}
...
@@ -140,7 +140,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
...
@@ -140,7 +140,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
if
(
!
next
.
table
[
c
-
min
])
{
if
(
!
next
.
table
[
c
-
min
])
{
next
.
table
[
c
-
min
]
=
new
(
std
::
nothrow
)
mtrie_t
;
next
.
table
[
c
-
min
]
=
new
(
std
::
nothrow
)
mtrie_t
;
++
live_nodes
;
++
live_nodes
;
zmq
_assert
(
next
.
table
[
c
-
min
]);
alloc
_assert
(
next
.
table
[
c
-
min
]);
}
}
return
next
.
table
[
c
-
min
]
->
add_helper
(
prefix_
+
1
,
size_
-
1
,
pipe_
);
return
next
.
table
[
c
-
min
]
->
add_helper
(
prefix_
+
1
,
size_
-
1
,
pipe_
);
}
}
...
@@ -260,7 +260,7 @@ void zmq::mtrie_t::rm_helper (pipe_t *pipe_, unsigned char **buff_,
...
@@ -260,7 +260,7 @@ void zmq::mtrie_t::rm_helper (pipe_t *pipe_, unsigned char **buff_,
count
=
new_max
-
new_min
+
1
;
count
=
new_max
-
new_min
+
1
;
next
.
table
=
(
mtrie_t
**
)
malloc
(
sizeof
(
mtrie_t
*
)
*
count
);
next
.
table
=
(
mtrie_t
**
)
malloc
(
sizeof
(
mtrie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
memmove
(
next
.
table
,
old_table
+
(
new_min
-
min
),
memmove
(
next
.
table
,
old_table
+
(
new_min
-
min
),
sizeof
(
mtrie_t
*
)
*
count
);
sizeof
(
mtrie_t
*
)
*
count
);
...
@@ -353,7 +353,7 @@ bool zmq::mtrie_t::rm_helper (unsigned char *prefix_, size_t size_,
...
@@ -353,7 +353,7 @@ bool zmq::mtrie_t::rm_helper (unsigned char *prefix_, size_t size_,
count
=
count
-
(
new_min
-
min
);
count
=
count
-
(
new_min
-
min
);
next
.
table
=
(
mtrie_t
**
)
malloc
(
sizeof
(
mtrie_t
*
)
*
count
);
next
.
table
=
(
mtrie_t
**
)
malloc
(
sizeof
(
mtrie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
memmove
(
next
.
table
,
old_table
+
(
new_min
-
min
),
memmove
(
next
.
table
,
old_table
+
(
new_min
-
min
),
sizeof
(
mtrie_t
*
)
*
count
);
sizeof
(
mtrie_t
*
)
*
count
);
...
@@ -375,7 +375,7 @@ bool zmq::mtrie_t::rm_helper (unsigned char *prefix_, size_t size_,
...
@@ -375,7 +375,7 @@ bool zmq::mtrie_t::rm_helper (unsigned char *prefix_, size_t size_,
mtrie_t
**
old_table
=
next
.
table
;
mtrie_t
**
old_table
=
next
.
table
;
next
.
table
=
(
mtrie_t
**
)
malloc
(
sizeof
(
mtrie_t
*
)
*
count
);
next
.
table
=
(
mtrie_t
**
)
malloc
(
sizeof
(
mtrie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
memmove
(
next
.
table
,
old_table
,
sizeof
(
mtrie_t
*
)
*
count
);
memmove
(
next
.
table
,
old_table
,
sizeof
(
mtrie_t
*
)
*
count
);
free
(
old_table
);
free
(
old_table
);
...
...
src/pgm_sender.cpp
View file @
24b79c7e
...
@@ -197,7 +197,7 @@ void zmq::pgm_sender_t::out_event ()
...
@@ -197,7 +197,7 @@ void zmq::pgm_sender_t::out_event ()
add_timer
(
timeout
,
tx_timer_id
);
add_timer
(
timeout
,
tx_timer_id
);
has_tx_timer
=
true
;
has_tx_timer
=
true
;
}
else
}
else
zmq
_assert
(
errno
==
EBUSY
);
errno
_assert
(
errno
==
EBUSY
);
}
}
}
}
...
...
src/session_base.cpp
View file @
24b79c7e
...
@@ -155,7 +155,8 @@ int zmq::session_base_t::read (msg_t *msg_)
...
@@ -155,7 +155,8 @@ int zmq::session_base_t::read (msg_t *msg_)
// First message to send is identity (if required).
// First message to send is identity (if required).
if
(
send_identity
)
{
if
(
send_identity
)
{
zmq_assert
(
!
(
msg_
->
flags
()
&
msg_t
::
more
));
zmq_assert
(
!
(
msg_
->
flags
()
&
msg_t
::
more
));
msg_
->
init_size
(
options
.
identity_size
);
int
rc
=
msg_
->
init_size
(
options
.
identity_size
);
errno_assert
(
rc
==
0
);
memcpy
(
msg_
->
data
(),
options
.
identity
,
options
.
identity_size
);
memcpy
(
msg_
->
data
(),
options
.
identity
,
options
.
identity_size
);
send_identity
=
false
;
send_identity
=
false
;
incomplete_in
=
false
;
incomplete_in
=
false
;
...
@@ -449,7 +450,7 @@ void zmq::session_base_t::start_connecting (bool wait_)
...
@@ -449,7 +450,7 @@ void zmq::session_base_t::start_connecting (bool wait_)
alloc_assert
(
pgm_sender
);
alloc_assert
(
pgm_sender
);
int
rc
=
pgm_sender
->
init
(
udp_encapsulation
,
addr
->
address
.
c_str
());
int
rc
=
pgm_sender
->
init
(
udp_encapsulation
,
addr
->
address
.
c_str
());
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
send_attach
(
this
,
pgm_sender
);
send_attach
(
this
,
pgm_sender
);
}
}
...
@@ -461,7 +462,7 @@ void zmq::session_base_t::start_connecting (bool wait_)
...
@@ -461,7 +462,7 @@ void zmq::session_base_t::start_connecting (bool wait_)
alloc_assert
(
pgm_receiver
);
alloc_assert
(
pgm_receiver
);
int
rc
=
pgm_receiver
->
init
(
udp_encapsulation
,
addr
->
address
.
c_str
());
int
rc
=
pgm_receiver
->
init
(
udp_encapsulation
,
addr
->
address
.
c_str
());
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
send_attach
(
this
,
pgm_receiver
);
send_attach
(
this
,
pgm_receiver
);
}
}
...
...
src/signaler.cpp
View file @
24b79c7e
...
@@ -144,7 +144,7 @@ int zmq::signaler_t::wait (int timeout_)
...
@@ -144,7 +144,7 @@ int zmq::signaler_t::wait (int timeout_)
pfd
.
events
=
POLLIN
;
pfd
.
events
=
POLLIN
;
int
rc
=
poll
(
&
pfd
,
1
,
timeout_
);
int
rc
=
poll
(
&
pfd
,
1
,
timeout_
);
if
(
unlikely
(
rc
<
0
))
{
if
(
unlikely
(
rc
<
0
))
{
zmq
_assert
(
errno
==
EINTR
);
errno
_assert
(
errno
==
EINTR
);
return
-
1
;
return
-
1
;
}
}
else
if
(
unlikely
(
rc
==
0
))
{
else
if
(
unlikely
(
rc
==
0
))
{
...
@@ -173,7 +173,7 @@ int zmq::signaler_t::wait (int timeout_)
...
@@ -173,7 +173,7 @@ int zmq::signaler_t::wait (int timeout_)
int
rc
=
select
(
r
+
1
,
&
fds
,
NULL
,
NULL
,
int
rc
=
select
(
r
+
1
,
&
fds
,
NULL
,
NULL
,
timeout_
>=
0
?
&
timeout
:
NULL
);
timeout_
>=
0
?
&
timeout
:
NULL
);
if
(
unlikely
(
rc
<
0
))
{
if
(
unlikely
(
rc
<
0
))
{
zmq
_assert
(
errno
==
EINTR
);
errno
_assert
(
errno
==
EINTR
);
return
-
1
;
return
-
1
;
}
}
#endif
#endif
...
...
src/socket_base.cpp
View file @
24b79c7e
...
@@ -448,7 +448,7 @@ int zmq::socket_base_t::connect (const char *addr_)
...
@@ -448,7 +448,7 @@ int zmq::socket_base_t::connect (const char *addr_)
if
(
options
.
send_identity
)
{
if
(
options
.
send_identity
)
{
msg_t
id
;
msg_t
id
;
rc
=
id
.
init_size
(
options
.
identity_size
);
rc
=
id
.
init_size
(
options
.
identity_size
);
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
memcpy
(
id
.
data
(),
options
.
identity
,
options
.
identity_size
);
memcpy
(
id
.
data
(),
options
.
identity
,
options
.
identity_size
);
id
.
set_flags
(
msg_t
::
identity
);
id
.
set_flags
(
msg_t
::
identity
);
bool
written
=
pipes
[
0
]
->
write
(
&
id
);
bool
written
=
pipes
[
0
]
->
write
(
&
id
);
...
@@ -460,7 +460,7 @@ int zmq::socket_base_t::connect (const char *addr_)
...
@@ -460,7 +460,7 @@ int zmq::socket_base_t::connect (const char *addr_)
if
(
peer
.
options
.
send_identity
)
{
if
(
peer
.
options
.
send_identity
)
{
msg_t
id
;
msg_t
id
;
rc
=
id
.
init_size
(
peer
.
options
.
identity_size
);
rc
=
id
.
init_size
(
peer
.
options
.
identity_size
);
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
memcpy
(
id
.
data
(),
peer
.
options
.
identity
,
peer
.
options
.
identity_size
);
memcpy
(
id
.
data
(),
peer
.
options
.
identity
,
peer
.
options
.
identity_size
);
id
.
set_flags
(
msg_t
::
identity
);
id
.
set_flags
(
msg_t
::
identity
);
bool
written
=
pipes
[
1
]
->
write
(
&
id
);
bool
written
=
pipes
[
1
]
->
write
(
&
id
);
...
@@ -487,12 +487,12 @@ int zmq::socket_base_t::connect (const char *addr_)
...
@@ -487,12 +487,12 @@ int zmq::socket_base_t::connect (const char *addr_)
}
}
address_t
*
paddr
=
new
(
std
::
nothrow
)
address_t
(
protocol
,
address
);
address_t
*
paddr
=
new
(
std
::
nothrow
)
address_t
(
protocol
,
address
);
zmq
_assert
(
paddr
);
alloc
_assert
(
paddr
);
// Resolve address (if needed by the protocol)
// Resolve address (if needed by the protocol)
if
(
protocol
==
"tcp"
)
{
if
(
protocol
==
"tcp"
)
{
paddr
->
resolved
.
tcp_addr
=
new
(
std
::
nothrow
)
tcp_address_t
();
paddr
->
resolved
.
tcp_addr
=
new
(
std
::
nothrow
)
tcp_address_t
();
zmq
_assert
(
paddr
->
resolved
.
tcp_addr
);
alloc
_assert
(
paddr
->
resolved
.
tcp_addr
);
int
rc
=
paddr
->
resolved
.
tcp_addr
->
resolve
(
int
rc
=
paddr
->
resolved
.
tcp_addr
->
resolve
(
address
.
c_str
(),
false
,
options
.
ipv4only
?
true
:
false
);
address
.
c_str
(),
false
,
options
.
ipv4only
?
true
:
false
);
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
...
@@ -503,7 +503,7 @@ int zmq::socket_base_t::connect (const char *addr_)
...
@@ -503,7 +503,7 @@ int zmq::socket_base_t::connect (const char *addr_)
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
else
if
(
protocol
==
"ipc"
)
{
else
if
(
protocol
==
"ipc"
)
{
paddr
->
resolved
.
ipc_addr
=
new
(
std
::
nothrow
)
ipc_address_t
();
paddr
->
resolved
.
ipc_addr
=
new
(
std
::
nothrow
)
ipc_address_t
();
zmq
_assert
(
paddr
->
resolved
.
ipc_addr
);
alloc
_assert
(
paddr
->
resolved
.
ipc_addr
);
int
rc
=
paddr
->
resolved
.
ipc_addr
->
resolve
(
address
.
c_str
());
int
rc
=
paddr
->
resolved
.
ipc_addr
->
resolve
(
address
.
c_str
());
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
delete
paddr
;
delete
paddr
;
...
...
src/tcp_address.cpp
View file @
24b79c7e
...
@@ -59,14 +59,14 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
...
@@ -59,14 +59,14 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
// Create a socket.
// Create a socket.
int
fd
=
open_socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
int
fd
=
open_socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
zmq
_assert
(
fd
!=
-
1
);
errno
_assert
(
fd
!=
-
1
);
// Retrieve number of interfaces.
// Retrieve number of interfaces.
lifnum
ifn
;
lifnum
ifn
;
ifn
.
lifn_family
=
AF_INET
;
ifn
.
lifn_family
=
AF_INET
;
ifn
.
lifn_flags
=
0
;
ifn
.
lifn_flags
=
0
;
int
rc
=
ioctl
(
fd
,
SIOCGLIFNUM
,
(
char
*
)
&
ifn
);
int
rc
=
ioctl
(
fd
,
SIOCGLIFNUM
,
(
char
*
)
&
ifn
);
zmq
_assert
(
rc
!=
-
1
);
errno
_assert
(
rc
!=
-
1
);
// Allocate memory to get interface names.
// Allocate memory to get interface names.
size_t
ifr_size
=
sizeof
(
struct
lifreq
)
*
ifn
.
lifn_count
;
size_t
ifr_size
=
sizeof
(
struct
lifreq
)
*
ifn
.
lifn_count
;
...
@@ -80,7 +80,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
...
@@ -80,7 +80,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
ifc
.
lifc_len
=
ifr_size
;
ifc
.
lifc_len
=
ifr_size
;
ifc
.
lifc_buf
=
ifr
;
ifc
.
lifc_buf
=
ifr
;
rc
=
ioctl
(
fd
,
SIOCGLIFCONF
,
(
char
*
)
&
ifc
);
rc
=
ioctl
(
fd
,
SIOCGLIFCONF
,
(
char
*
)
&
ifc
);
zmq
_assert
(
rc
!=
-
1
);
errno
_assert
(
rc
!=
-
1
);
// Find the interface with the specified name and AF_INET family.
// Find the interface with the specified name and AF_INET family.
bool
found
=
false
;
bool
found
=
false
;
...
@@ -89,7 +89,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
...
@@ -89,7 +89,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
n
++
,
ifrp
++
)
{
n
++
,
ifrp
++
)
{
if
(
!
strcmp
(
nic_
,
ifrp
->
lifr_name
))
{
if
(
!
strcmp
(
nic_
,
ifrp
->
lifr_name
))
{
rc
=
ioctl
(
fd
,
SIOCGLIFADDR
,
(
char
*
)
ifrp
);
rc
=
ioctl
(
fd
,
SIOCGLIFADDR
,
(
char
*
)
ifrp
);
zmq
_assert
(
rc
!=
-
1
);
errno
_assert
(
rc
!=
-
1
);
if
(
ifrp
->
lifr_addr
.
ss_family
==
AF_INET
)
{
if
(
ifrp
->
lifr_addr
.
ss_family
==
AF_INET
)
{
address
.
ipv4
=
*
(
sockaddr_in
*
)
&
ifrp
->
lifr_addr
;
address
.
ipv4
=
*
(
sockaddr_in
*
)
&
ifrp
->
lifr_addr
;
found
=
true
;
found
=
true
;
...
@@ -124,7 +124,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
...
@@ -124,7 +124,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
// Create a socket.
// Create a socket.
int
sd
=
open_socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
int
sd
=
open_socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
zmq
_assert
(
sd
!=
-
1
);
errno
_assert
(
sd
!=
-
1
);
struct
ifreq
ifr
;
struct
ifreq
ifr
;
...
@@ -162,7 +162,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
...
@@ -162,7 +162,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
// Get the addresses.
// Get the addresses.
ifaddrs
*
ifa
=
NULL
;
ifaddrs
*
ifa
=
NULL
;
int
rc
=
getifaddrs
(
&
ifa
);
int
rc
=
getifaddrs
(
&
ifa
);
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
zmq_assert
(
ifa
!=
NULL
);
zmq_assert
(
ifa
!=
NULL
);
// Find the corresponding network interface.
// Find the corresponding network interface.
...
...
src/trie.cpp
View file @
24b79c7e
...
@@ -80,7 +80,7 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
...
@@ -80,7 +80,7 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
count
=
(
min
<
c
?
c
-
min
:
min
-
c
)
+
1
;
count
=
(
min
<
c
?
c
-
min
:
min
-
c
)
+
1
;
next
.
table
=
(
trie_t
**
)
next
.
table
=
(
trie_t
**
)
malloc
(
sizeof
(
trie_t
*
)
*
count
);
malloc
(
sizeof
(
trie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
for
(
unsigned
short
i
=
0
;
i
!=
count
;
++
i
)
for
(
unsigned
short
i
=
0
;
i
!=
count
;
++
i
)
next
.
table
[
i
]
=
0
;
next
.
table
[
i
]
=
0
;
min
=
std
::
min
(
min
,
c
);
min
=
std
::
min
(
min
,
c
);
...
@@ -117,7 +117,7 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
...
@@ -117,7 +117,7 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
if
(
count
==
1
)
{
if
(
count
==
1
)
{
if
(
!
next
.
node
)
{
if
(
!
next
.
node
)
{
next
.
node
=
new
(
std
::
nothrow
)
trie_t
;
next
.
node
=
new
(
std
::
nothrow
)
trie_t
;
zmq
_assert
(
next
.
node
);
alloc
_assert
(
next
.
node
);
++
live_nodes
;
++
live_nodes
;
zmq_assert
(
live_nodes
==
1
);
zmq_assert
(
live_nodes
==
1
);
}
}
...
@@ -126,7 +126,7 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
...
@@ -126,7 +126,7 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
else
{
else
{
if
(
!
next
.
table
[
c
-
min
])
{
if
(
!
next
.
table
[
c
-
min
])
{
next
.
table
[
c
-
min
]
=
new
(
std
::
nothrow
)
trie_t
;
next
.
table
[
c
-
min
]
=
new
(
std
::
nothrow
)
trie_t
;
zmq
_assert
(
next
.
table
[
c
-
min
]);
alloc
_assert
(
next
.
table
[
c
-
min
]);
++
live_nodes
;
++
live_nodes
;
zmq_assert
(
live_nodes
>
1
);
zmq_assert
(
live_nodes
>
1
);
}
}
...
@@ -218,7 +218,7 @@ bool zmq::trie_t::rm (unsigned char *prefix_, size_t size_)
...
@@ -218,7 +218,7 @@ bool zmq::trie_t::rm (unsigned char *prefix_, size_t size_)
count
=
count
-
(
new_min
-
min
);
count
=
count
-
(
new_min
-
min
);
next
.
table
=
(
trie_t
**
)
malloc
(
sizeof
(
trie_t
*
)
*
count
);
next
.
table
=
(
trie_t
**
)
malloc
(
sizeof
(
trie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
memmove
(
next
.
table
,
old_table
+
(
new_min
-
min
),
memmove
(
next
.
table
,
old_table
+
(
new_min
-
min
),
sizeof
(
trie_t
*
)
*
count
);
sizeof
(
trie_t
*
)
*
count
);
...
@@ -242,7 +242,7 @@ bool zmq::trie_t::rm (unsigned char *prefix_, size_t size_)
...
@@ -242,7 +242,7 @@ bool zmq::trie_t::rm (unsigned char *prefix_, size_t size_)
trie_t
**
old_table
=
next
.
table
;
trie_t
**
old_table
=
next
.
table
;
next
.
table
=
(
trie_t
**
)
malloc
(
sizeof
(
trie_t
*
)
*
count
);
next
.
table
=
(
trie_t
**
)
malloc
(
sizeof
(
trie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
memmove
(
next
.
table
,
old_table
,
sizeof
(
trie_t
*
)
*
count
);
memmove
(
next
.
table
,
old_table
,
sizeof
(
trie_t
*
)
*
count
);
free
(
old_table
);
free
(
old_table
);
...
...
src/xsub.cpp
View file @
24b79c7e
...
@@ -150,7 +150,7 @@ int zmq::xsub_t::xrecv (msg_t *msg_, int flags_)
...
@@ -150,7 +150,7 @@ int zmq::xsub_t::xrecv (msg_t *msg_, int flags_)
// from the pipe.
// from the pipe.
while
(
msg_
->
flags
()
&
msg_t
::
more
)
{
while
(
msg_
->
flags
()
&
msg_t
::
more
)
{
rc
=
fq
.
recv
(
msg_
);
rc
=
fq
.
recv
(
msg_
);
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
}
}
}
}
}
}
...
@@ -176,7 +176,7 @@ bool zmq::xsub_t::xhas_in ()
...
@@ -176,7 +176,7 @@ bool zmq::xsub_t::xhas_in ()
// If there's no message available, return immediately.
// If there's no message available, return immediately.
// The same when error occurs.
// The same when error occurs.
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
zmq
_assert
(
errno
==
EAGAIN
);
errno
_assert
(
errno
==
EAGAIN
);
return
false
;
return
false
;
}
}
...
@@ -190,7 +190,7 @@ bool zmq::xsub_t::xhas_in ()
...
@@ -190,7 +190,7 @@ bool zmq::xsub_t::xhas_in ()
// from the pipe.
// from the pipe.
while
(
message
.
flags
()
&
msg_t
::
more
)
{
while
(
message
.
flags
()
&
msg_t
::
more
)
{
rc
=
fq
.
recv
(
&
message
);
rc
=
fq
.
recv
(
&
message
);
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
}
}
}
}
}
}
...
@@ -208,7 +208,7 @@ void zmq::xsub_t::send_subscription (unsigned char *data_, size_t size_,
...
@@ -208,7 +208,7 @@ void zmq::xsub_t::send_subscription (unsigned char *data_, size_t size_,
// Create the subsctription message.
// Create the subsctription message.
msg_t
msg
;
msg_t
msg
;
int
rc
=
msg
.
init_size
(
size_
+
1
);
int
rc
=
msg
.
init_size
(
size_
+
1
);
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
unsigned
char
*
data
=
(
unsigned
char
*
)
msg
.
data
();
unsigned
char
*
data
=
(
unsigned
char
*
)
msg
.
data
();
data
[
0
]
=
1
;
data
[
0
]
=
1
;
memcpy
(
data
+
1
,
data_
,
size_
);
memcpy
(
data
+
1
,
data_
,
size_
);
...
...
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