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
350a1ac1
Commit
350a1ac1
authored
Mar 12, 2014
by
Mark Barbisan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow TCP addresses to be re-resolved whenever there is a reconnection attempt
parent
52db50f8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
25 deletions
+37
-25
req.cpp
src/req.cpp
+1
-1
req.hpp
src/req.hpp
+1
-1
session_base.cpp
src/session_base.cpp
+2
-2
session_base.hpp
src/session_base.hpp
+3
-3
socket_base.cpp
src/socket_base.cpp
+2
-8
tcp_connecter.cpp
src/tcp_connecter.cpp
+20
-2
tcp_connecter.hpp
src/tcp_connecter.hpp
+2
-2
test_connect_resolve.cpp
tests/test_connect_resolve.cpp
+6
-6
No files found.
src/req.cpp
View file @
350a1ac1
...
...
@@ -240,7 +240,7 @@ int zmq::req_t::recv_reply_pipe (msg_t *msg_)
zmq
::
req_session_t
::
req_session_t
(
io_thread_t
*
io_thread_
,
bool
connect_
,
socket_base_t
*
socket_
,
const
options_t
&
options_
,
const
address_t
*
addr_
)
:
address_t
*
addr_
)
:
session_base_t
(
io_thread_
,
connect_
,
socket_
,
options_
,
addr_
),
state
(
bottom
)
{
...
...
src/req.hpp
View file @
350a1ac1
...
...
@@ -87,7 +87,7 @@ namespace zmq
req_session_t
(
zmq
::
io_thread_t
*
io_thread_
,
bool
connect_
,
zmq
::
socket_base_t
*
socket_
,
const
options_t
&
options_
,
const
address_t
*
addr_
);
address_t
*
addr_
);
~
req_session_t
();
// Overrides of the functions from session_base_t.
...
...
src/session_base.cpp
View file @
350a1ac1
...
...
@@ -34,7 +34,7 @@
zmq
::
session_base_t
*
zmq
::
session_base_t
::
create
(
class
io_thread_t
*
io_thread_
,
bool
active_
,
class
socket_base_t
*
socket_
,
const
options_t
&
options_
,
const
address_t
*
addr_
)
address_t
*
addr_
)
{
session_base_t
*
s
=
NULL
;
...
...
@@ -67,7 +67,7 @@ zmq::session_base_t *zmq::session_base_t::create (class io_thread_t *io_thread_,
zmq
::
session_base_t
::
session_base_t
(
class
io_thread_t
*
io_thread_
,
bool
active_
,
class
socket_base_t
*
socket_
,
const
options_t
&
options_
,
const
address_t
*
addr_
)
:
address_t
*
addr_
)
:
own_t
(
io_thread_
,
options_
),
io_object_t
(
io_thread_
),
active
(
active_
),
...
...
src/session_base.hpp
View file @
350a1ac1
...
...
@@ -47,7 +47,7 @@ namespace zmq
// Create a session of the particular type.
static
session_base_t
*
create
(
zmq
::
io_thread_t
*
io_thread_
,
bool
active_
,
zmq
::
socket_base_t
*
socket_
,
const
options_t
&
options_
,
const
address_t
*
addr_
);
const
options_t
&
options_
,
address_t
*
addr_
);
// To be used once only, when creating the session.
void
attach_pipe
(
zmq
::
pipe_t
*
pipe_
);
...
...
@@ -90,7 +90,7 @@ namespace zmq
session_base_t
(
zmq
::
io_thread_t
*
io_thread_
,
bool
active_
,
zmq
::
socket_base_t
*
socket_
,
const
options_t
&
options_
,
const
address_t
*
addr_
);
address_t
*
addr_
);
virtual
~
session_base_t
();
private
:
...
...
@@ -152,7 +152,7 @@ namespace zmq
bool
has_linger_timer
;
// Protocol and address to use when connecting.
const
address_t
*
addr
;
address_t
*
addr
;
session_base_t
(
const
session_base_t
&
);
const
session_base_t
&
operator
=
(
const
session_base_t
&
);
...
...
src/socket_base.cpp
View file @
350a1ac1
...
...
@@ -585,14 +585,8 @@ int zmq::socket_base_t::connect (const char *addr_)
// Resolve address (if needed by the protocol)
if
(
protocol
==
"tcp"
)
{
paddr
->
resolved
.
tcp_addr
=
new
(
std
::
nothrow
)
tcp_address_t
();
alloc_assert
(
paddr
->
resolved
.
tcp_addr
);
int
rc
=
paddr
->
resolved
.
tcp_addr
->
resolve
(
address
.
c_str
(),
false
,
options
.
ipv6
);
if
(
rc
!=
0
)
{
delete
paddr
;
return
-
1
;
}
// Defer resolution until a socket is opened
paddr
->
resolved
.
tcp_addr
=
NULL
;
}
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
else
...
...
src/tcp_connecter.cpp
View file @
350a1ac1
...
...
@@ -50,7 +50,7 @@
zmq
::
tcp_connecter_t
::
tcp_connecter_t
(
class
io_thread_t
*
io_thread_
,
class
session_base_t
*
session_
,
const
options_t
&
options_
,
const
address_t
*
addr_
,
bool
delayed_start_
)
:
address_t
*
addr_
,
bool
delayed_start_
)
:
own_t
(
io_thread_
,
options_
),
io_object_t
(
io_thread_
),
addr
(
addr_
),
...
...
@@ -209,6 +209,24 @@ int zmq::tcp_connecter_t::open ()
{
zmq_assert
(
s
==
retired_fd
);
// Resolve the address
if
(
addr
->
resolved
.
tcp_addr
!=
NULL
)
{
delete
addr
->
resolved
.
tcp_addr
;
addr
->
resolved
.
tcp_addr
=
NULL
;
}
zmq_assert
(
addr
->
resolved
.
tcp_addr
==
NULL
);
addr
->
resolved
.
tcp_addr
=
new
(
std
::
nothrow
)
tcp_address_t
();
alloc_assert
(
addr
->
resolved
.
tcp_addr
);
int
rc
=
addr
->
resolved
.
tcp_addr
->
resolve
(
addr
->
address
.
c_str
(),
false
,
options
.
ipv6
);
if
(
rc
!=
0
)
{
delete
addr
->
resolved
.
tcp_addr
;
addr
->
resolved
.
tcp_addr
=
NULL
;
return
-
1
;
}
zmq_assert
(
addr
->
resolved
.
tcp_addr
!=
NULL
);
// Create the socket.
s
=
open_socket
(
addr
->
resolved
.
tcp_addr
->
family
(),
SOCK_STREAM
,
IPPROTO_TCP
);
#ifdef ZMQ_HAVE_WINDOWS
...
...
@@ -244,7 +262,7 @@ int zmq::tcp_connecter_t::open ()
set_ip_type_of_service
(
s
,
options
.
tos
);
// Connect to the remote peer.
int
rc
=
::
connect
(
rc
=
::
connect
(
s
,
addr
->
resolved
.
tcp_addr
->
addr
(),
addr
->
resolved
.
tcp_addr
->
addrlen
());
...
...
src/tcp_connecter.hpp
View file @
350a1ac1
...
...
@@ -41,7 +41,7 @@ namespace zmq
// then starts connection process.
tcp_connecter_t
(
zmq
::
io_thread_t
*
io_thread_
,
zmq
::
session_base_t
*
session_
,
const
options_t
&
options_
,
const
address_t
*
addr_
,
bool
delayed_start_
);
address_t
*
addr_
,
bool
delayed_start_
);
~
tcp_connecter_t
();
private
:
...
...
@@ -82,7 +82,7 @@ namespace zmq
fd_t
connect
();
// Address to connect to. Owned by session_base_t.
const
address_t
*
addr
;
address_t
*
addr
;
// Underlying socket.
fd_t
s
;
...
...
tests/test_connect_resolve.cpp
View file @
350a1ac1
...
...
@@ -30,15 +30,15 @@ int main (void)
int
rc
=
zmq_connect
(
sock
,
"tcp://localhost:1234"
);
assert
(
rc
==
0
);
// Because of lazy resolution of TCP names, this will succeed
rc
=
zmq_connect
(
sock
,
"tcp://localhost:invalid"
);
assert
(
rc
==
-
1
);
assert
(
errno
==
EINVAL
);
assert
(
rc
==
0
);
// Because of lazy resolution of TCP names, this will succeed
rc
=
zmq_connect
(
sock
,
"tcp://in val id:1234"
);
assert
(
rc
==
-
1
);
assert
(
errno
==
EINVAL
);
assert
(
rc
==
0
);
rc
=
zmq_connect
(
sock
,
"invalid://localhost:1234"
);
assert
(
rc
==
-
1
);
assert
(
errno
==
EPROTONOSUPPORT
);
...
...
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