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
3455be14
Commit
3455be14
authored
Aug 15, 2018
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: code duplication around sending of routing id
Solution: extract functionality into send_routing_id
parent
83f41526
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
35 deletions
+19
-35
ctx.cpp
src/ctx.cpp
+1
-9
pipe.cpp
src/pipe.cpp
+12
-0
pipe.hpp
src/pipe.hpp
+3
-0
socket_base.cpp
src/socket_base.cpp
+3
-26
No files found.
src/ctx.cpp
View file @
3455be14
...
...
@@ -652,15 +652,7 @@ void zmq::ctx_t::connect_inproc_sockets (
// is open before sending.
if
(
pending_connection_
.
endpoint
.
options
.
recv_routing_id
&&
pending_connection_
.
endpoint
.
socket
->
check_tag
())
{
msg_t
routing_id
;
const
int
rc
=
routing_id
.
init_size
(
bind_options_
.
routing_id_size
);
errno_assert
(
rc
==
0
);
memcpy
(
routing_id
.
data
(),
bind_options_
.
routing_id
,
bind_options_
.
routing_id_size
);
routing_id
.
set_flags
(
msg_t
::
routing_id
);
const
bool
written
=
pending_connection_
.
bind_pipe
->
write
(
&
routing_id
);
zmq_assert
(
written
);
pending_connection_
.
bind_pipe
->
flush
();
send_routing_id
(
pending_connection_
.
bind_pipe
,
bind_options_
);
}
}
...
...
src/pipe.cpp
View file @
3455be14
...
...
@@ -76,6 +76,18 @@ int zmq::pipepair (class object_t *parents_[2],
return
0
;
}
void
zmq
::
send_routing_id
(
pipe_t
*
pipe_
,
const
options_t
&
options_
)
{
zmq
::
msg_t
id
;
const
int
rc
=
id
.
init_size
(
options_
.
routing_id_size
);
errno_assert
(
rc
==
0
);
memcpy
(
id
.
data
(),
options_
.
routing_id
,
options_
.
routing_id_size
);
id
.
set_flags
(
zmq
::
msg_t
::
routing_id
);
const
bool
written
=
pipe_
->
write
(
&
id
);
zmq_assert
(
written
);
pipe_
->
flush
();
}
zmq
::
pipe_t
::
pipe_t
(
object_t
*
parent_
,
upipe_t
*
inpipe_
,
upipe_t
*
outpipe_
,
...
...
src/pipe.hpp
View file @
3455be14
...
...
@@ -36,6 +36,7 @@
#include "stdint.hpp"
#include "array.hpp"
#include "blob.hpp"
#include "options.hpp"
namespace
zmq
{
...
...
@@ -247,6 +248,8 @@ class pipe_t : public object_t,
pipe_t
(
const
pipe_t
&
);
const
pipe_t
&
operator
=
(
const
pipe_t
&
);
};
void
send_routing_id
(
pipe_t
*
pipe_
,
const
options_t
&
options_
);
}
#endif
src/socket_base.cpp
View file @
3455be14
...
...
@@ -721,42 +721,19 @@ int zmq::socket_base_t::connect (const char *addr_)
// to send the routing id message or not. To resolve this,
// we always send our routing id and drop it later if
// the peer doesn't expect it.
msg_t
id
;
rc
=
id
.
init_size
(
options
.
routing_id_size
);
errno_assert
(
rc
==
0
);
memcpy
(
id
.
data
(),
options
.
routing_id
,
options
.
routing_id_size
);
id
.
set_flags
(
msg_t
::
routing_id
);
const
bool
written
=
new_pipes
[
0
]
->
write
(
&
id
);
zmq_assert
(
written
);
new_pipes
[
0
]
->
flush
();
send_routing_id
(
new_pipes
[
0
],
options
);
const
endpoint_t
endpoint
=
{
this
,
options
};
pend_connection
(
std
::
string
(
addr_
),
endpoint
,
new_pipes
);
}
else
{
// If required, send the routing id of the local socket to the peer.
if
(
peer
.
options
.
recv_routing_id
)
{
msg_t
id
;
rc
=
id
.
init_size
(
options
.
routing_id_size
);
errno_assert
(
rc
==
0
);
memcpy
(
id
.
data
(),
options
.
routing_id
,
options
.
routing_id_size
);
id
.
set_flags
(
msg_t
::
routing_id
);
const
bool
written
=
new_pipes
[
0
]
->
write
(
&
id
);
zmq_assert
(
written
);
new_pipes
[
0
]
->
flush
();
send_routing_id
(
new_pipes
[
0
],
options
);
}
// If required, send the routing id of the peer to the local socket.
if
(
options
.
recv_routing_id
)
{
msg_t
id
;
rc
=
id
.
init_size
(
peer
.
options
.
routing_id_size
);
errno_assert
(
rc
==
0
);
memcpy
(
id
.
data
(),
peer
.
options
.
routing_id
,
peer
.
options
.
routing_id_size
);
id
.
set_flags
(
msg_t
::
routing_id
);
const
bool
written
=
new_pipes
[
1
]
->
write
(
&
id
);
zmq_assert
(
written
);
new_pipes
[
1
]
->
flush
();
send_routing_id
(
new_pipes
[
1
],
peer
.
options
);
}
// Attach remote end of the pipe to the peer socket. Note that peer's
...
...
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