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
eb42e044
Unverified
Commit
eb42e044
authored
Feb 07, 2019
by
Luca Boccassi
Committed by
GitHub
Feb 07, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3396 from sigiesec/fix-issue-3394
Fix regression introduced by
68d520ef
parents
5ecf8f93
a763d734
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
51 additions
and
10 deletions
+51
-10
mailbox_safe.cpp
src/mailbox_safe.cpp
+1
-2
socks_connecter.cpp
src/socks_connecter.cpp
+6
-1
tcp.cpp
src/tcp.cpp
+3
-5
tcp.hpp
src/tcp.hpp
+1
-0
tcp_connecter.cpp
src/tcp_connecter.cpp
+6
-1
tcp_listener.cpp
src/tcp_listener.cpp
+1
-1
test_pair_tcp.cpp
tests/test_pair_tcp.cpp
+31
-0
testutil_unity.hpp
tests/testutil_unity.hpp
+2
-0
No files found.
src/mailbox_safe.cpp
View file @
eb42e044
...
...
@@ -104,8 +104,7 @@ int zmq::mailbox_safe_t::recv (command_t *cmd_, int timeout_)
if
(
timeout_
==
0
)
{
_sync
->
unlock
();
_sync
->
lock
();
}
else
{
}
else
{
// Wait for signal from the command sender.
int
rc
=
_cond_var
.
wait
(
_sync
,
timeout_
);
if
(
rc
==
-
1
)
{
...
...
src/socks_connecter.cpp
View file @
eb42e044
...
...
@@ -224,14 +224,19 @@ int zmq::socks_connecter_t::connect_to_proxy ()
// Automatic fallback to ipv4 is disabled here since this was the existing
// behaviour, however I don't see a real reason for this. Maybe this can
// be changed to true (and then the parameter can be removed entirely).
_s
=
tcp_open_socket
(
_addr
->
address
.
c_str
(),
options
,
false
,
_s
=
tcp_open_socket
(
_addr
->
address
.
c_str
(),
options
,
false
,
false
,
_addr
->
resolved
.
tcp_addr
);
if
(
_s
==
retired_fd
)
{
// TODO we should emit some event in this case!
LIBZMQ_DELETE
(
_addr
->
resolved
.
tcp_addr
);
return
-
1
;
}
zmq_assert
(
_addr
->
resolved
.
tcp_addr
!=
NULL
);
// Set the socket to non-blocking mode so that we get async connect().
unblock_socket
(
_s
);
const
tcp_address_t
*
const
tcp_addr
=
_addr
->
resolved
.
tcp_addr
;
int
rc
;
...
...
src/tcp.cpp
View file @
eb42e044
...
...
@@ -385,11 +385,12 @@ void zmq::tcp_tune_loopback_fast_path (const fd_t socket_)
zmq
::
fd_t
zmq
::
tcp_open_socket
(
const
char
*
address_
,
const
zmq
::
options_t
&
options_
,
bool
local_
,
bool
fallback_to_ipv4_
,
zmq
::
tcp_address_t
*
out_tcp_addr_
)
{
// Convert the textual address into address structure.
int
rc
=
out_tcp_addr_
->
resolve
(
address_
,
true
,
options_
.
ipv6
);
int
rc
=
out_tcp_addr_
->
resolve
(
address_
,
local_
,
options_
.
ipv6
);
if
(
rc
!=
0
)
return
retired_fd
;
...
...
@@ -400,7 +401,7 @@ zmq::fd_t zmq::tcp_open_socket (const char *address_,
if
(
s
==
retired_fd
&&
fallback_to_ipv4_
&&
out_tcp_addr_
->
family
()
==
AF_INET6
&&
errno
==
EAFNOSUPPORT
&&
options_
.
ipv6
)
{
rc
=
out_tcp_addr_
->
resolve
(
address_
,
false
,
false
);
rc
=
out_tcp_addr_
->
resolve
(
address_
,
local_
,
false
);
if
(
rc
!=
0
)
{
return
retired_fd
;
}
...
...
@@ -428,9 +429,6 @@ zmq::fd_t zmq::tcp_open_socket (const char *address_,
if
(
!
options_
.
bound_device
.
empty
())
bind_to_device
(
s
,
options_
.
bound_device
);
// Set the socket to non-blocking mode so that we get async connect().
unblock_socket
(
s
);
// Set the socket buffer limits for the underlying socket.
if
(
options_
.
sndbuf
>=
0
)
set_tcp_send_buffer
(
s
,
options_
.
sndbuf
);
...
...
src/tcp.hpp
View file @
eb42e044
...
...
@@ -79,6 +79,7 @@ void tcp_tune_loopback_fast_path (const fd_t socket_);
// errno is set to an error code describing the cause of the error.
fd_t
tcp_open_socket
(
const
char
*
address_
,
const
options_t
&
options_
,
bool
local_
,
bool
fallback_to_ipv4_
,
tcp_address_t
*
out_tcp_addr_
);
}
...
...
src/tcp_connecter.cpp
View file @
eb42e044
...
...
@@ -174,14 +174,19 @@ int zmq::tcp_connecter_t::open ()
_addr
->
resolved
.
tcp_addr
=
new
(
std
::
nothrow
)
tcp_address_t
();
alloc_assert
(
_addr
->
resolved
.
tcp_addr
);
_s
=
tcp_open_socket
(
_addr
->
address
.
c_str
(),
options
,
true
,
_s
=
tcp_open_socket
(
_addr
->
address
.
c_str
(),
options
,
false
,
true
,
_addr
->
resolved
.
tcp_addr
);
if
(
_s
==
retired_fd
)
{
// TODO we should emit some event in this case!
LIBZMQ_DELETE
(
_addr
->
resolved
.
tcp_addr
);
return
-
1
;
}
zmq_assert
(
_addr
->
resolved
.
tcp_addr
!=
NULL
);
// Set the socket to non-blocking mode so that we get async connect().
unblock_socket
(
_s
);
const
tcp_address_t
*
const
tcp_addr
=
_addr
->
resolved
.
tcp_addr
;
int
rc
;
...
...
src/tcp_listener.cpp
View file @
eb42e044
...
...
@@ -103,7 +103,7 @@ zmq::tcp_listener_t::get_socket_name (zmq::fd_t fd_,
int
zmq
::
tcp_listener_t
::
create_socket
(
const
char
*
addr_
)
{
_s
=
tcp_open_socket
(
addr_
,
options
,
true
,
&
_address
);
_s
=
tcp_open_socket
(
addr_
,
options
,
true
,
true
,
&
_address
);
if
(
_s
==
retired_fd
)
{
return
-
1
;
}
...
...
tests/test_pair_tcp.cpp
View file @
eb42e044
...
...
@@ -80,6 +80,36 @@ void test_pair_tcp_regular ()
test_pair_tcp
();
}
void
test_pair_tcp_connect_by_name
()
{
// all other tcp test cases bind to a loopback wildcard address, then
// retrieve the bound endpoint, which is numerical, and use that to
// connect. this test cases specifically uses "localhost" to connect
// to ensure that names are correctly resolved
void
*
sb
=
test_context_socket
(
ZMQ_PAIR
);
char
bound_endpoint
[
MAX_SOCKET_STRING
];
bind_loopback_ipv4
(
sb
,
bound_endpoint
,
sizeof
bound_endpoint
);
// extract the bound port number
const
char
*
pos
=
strrchr
(
bound_endpoint
,
':'
);
TEST_ASSERT_NOT_NULL
(
pos
);
const
char
connect_endpoint_prefix
[]
=
"tcp://localhost"
;
char
connect_endpoint
[
MAX_SOCKET_STRING
];
strcpy
(
connect_endpoint
,
connect_endpoint_prefix
);
strcat
(
connect_endpoint
,
pos
);
void
*
sc
=
test_context_socket
(
ZMQ_PAIR
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_connect
(
sc
,
connect_endpoint
));
bounce
(
sb
,
sc
);
test_context_socket_close
(
sc
);
test_context_socket_close
(
sb
);
}
#ifdef ZMQ_BUILD_DRAFT
void
test_pair_tcp_fastpath
()
{
...
...
@@ -93,6 +123,7 @@ int main ()
UNITY_BEGIN
();
RUN_TEST
(
test_pair_tcp_regular
);
RUN_TEST
(
test_pair_tcp_connect_by_name
);
#ifdef ZMQ_BUILD_DRAFT
RUN_TEST
(
test_pair_tcp_fastpath
);
#endif
...
...
tests/testutil_unity.hpp
View file @
eb42e044
...
...
@@ -347,6 +347,7 @@ void bind_loopback_tipc (void *socket_, char *my_endpoint_, size_t len_)
test_bind
(
socket_
,
"tipc://<*>"
,
my_endpoint_
,
len_
);
}
#if !defined(ZMQ_HAVE_WINDOWS) && !defined(ZMQ_HAVE_GNU)
// utility function to create a random IPC endpoint, similar to what a ipc://*
// wildcard binding does, but in a way it can be reused for multiple binds
void
make_random_ipc_endpoint
(
char
*
out_endpoint_
)
...
...
@@ -366,3 +367,4 @@ void make_random_ipc_endpoint (char *out_endpoint_)
strcpy
(
out_endpoint_
,
"ipc://"
);
strcat
(
out_endpoint_
,
random_file
);
}
#endif
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