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
2e78e485
Commit
2e78e485
authored
Feb 12, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Multi-hop REQ/REP, part V., peer identity is passed from init object to session
parent
d8430f4b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
7 deletions
+42
-7
command.cpp
src/command.cpp
+10
-0
command.hpp
src/command.hpp
+2
-0
object.cpp
src/object.cpp
+20
-2
object.hpp
src/object.hpp
+4
-2
session.cpp
src/session.cpp
+2
-1
session.hpp
src/session.hpp
+2
-1
zmq_init.cpp
src/zmq_init.cpp
+2
-1
No files found.
src/command.cpp
View file @
2e78e485
...
@@ -17,8 +17,18 @@
...
@@ -17,8 +17,18 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <stdlib.h>
#include "command.hpp"
#include "command.hpp"
void
zmq
::
deallocate_command
(
command_t
*
cmd_
)
void
zmq
::
deallocate_command
(
command_t
*
cmd_
)
{
{
switch
(
cmd_
->
type
)
{
case
command_t
:
:
attach
:
if
(
cmd_
->
args
.
attach
.
peer_identity
)
free
(
cmd_
->
args
.
attach
.
peer_identity
);
break
;
default
:
/* noop */
;
}
}
}
src/command.hpp
View file @
2e78e485
...
@@ -66,6 +66,8 @@ namespace zmq
...
@@ -66,6 +66,8 @@ namespace zmq
// Attach the engine to the session.
// Attach the engine to the session.
struct
{
struct
{
struct
i_engine
*
engine
;
struct
i_engine
*
engine
;
unsigned
char
peer_identity_size
;
unsigned
char
*
peer_identity
;
}
attach
;
}
attach
;
// Sent from session to socket to establish pipe(s) between them.
// Sent from session to socket to establish pipe(s) between them.
...
...
src/object.cpp
View file @
2e78e485
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <string.h>
#include "object.hpp"
#include "object.hpp"
#include "dispatcher.hpp"
#include "dispatcher.hpp"
#include "err.hpp"
#include "err.hpp"
...
@@ -80,7 +82,9 @@ void zmq::object_t::process_command (command_t &cmd_)
...
@@ -80,7 +82,9 @@ void zmq::object_t::process_command (command_t &cmd_)
break
;
break
;
case
command_t
:
:
attach
:
case
command_t
:
:
attach
:
process_attach
(
cmd_
.
args
.
attach
.
engine
);
process_attach
(
cmd_
.
args
.
attach
.
engine
,
cmd_
.
args
.
attach
.
peer_identity_size
,
cmd_
.
args
.
attach
.
peer_identity
);
process_seqnum
();
process_seqnum
();
break
;
break
;
...
@@ -180,6 +184,7 @@ void zmq::object_t::send_own (socket_base_t *destination_, owned_t *object_)
...
@@ -180,6 +184,7 @@ void zmq::object_t::send_own (socket_base_t *destination_, owned_t *object_)
}
}
void
zmq
::
object_t
::
send_attach
(
session_t
*
destination_
,
i_engine
*
engine_
,
void
zmq
::
object_t
::
send_attach
(
session_t
*
destination_
,
i_engine
*
engine_
,
unsigned
char
peer_identity_size_
,
unsigned
char
*
peer_identity_
,
bool
inc_seqnum_
)
bool
inc_seqnum_
)
{
{
if
(
inc_seqnum_
)
if
(
inc_seqnum_
)
...
@@ -189,6 +194,18 @@ void zmq::object_t::send_attach (session_t *destination_, i_engine *engine_,
...
@@ -189,6 +194,18 @@ void zmq::object_t::send_attach (session_t *destination_, i_engine *engine_,
cmd
.
destination
=
destination_
;
cmd
.
destination
=
destination_
;
cmd
.
type
=
command_t
::
attach
;
cmd
.
type
=
command_t
::
attach
;
cmd
.
args
.
attach
.
engine
=
engine_
;
cmd
.
args
.
attach
.
engine
=
engine_
;
if
(
!
peer_identity_size_
)
{
cmd
.
args
.
attach
.
peer_identity_size
=
0
;
cmd
.
args
.
attach
.
peer_identity
=
NULL
;
}
else
{
cmd
.
args
.
attach
.
peer_identity_size
=
peer_identity_size_
;
cmd
.
args
.
attach
.
peer_identity
=
(
unsigned
char
*
)
malloc
(
peer_identity_size_
);
zmq_assert
(
cmd
.
args
.
attach
.
peer_identity_size
);
memcpy
(
cmd
.
args
.
attach
.
peer_identity
,
peer_identity_
,
peer_identity_size_
);
}
send_command
(
cmd
);
send_command
(
cmd
);
}
}
...
@@ -271,7 +288,8 @@ void zmq::object_t::process_own (owned_t *object_)
...
@@ -271,7 +288,8 @@ void zmq::object_t::process_own (owned_t *object_)
zmq_assert
(
false
);
zmq_assert
(
false
);
}
}
void
zmq
::
object_t
::
process_attach
(
i_engine
*
engine_
)
void
zmq
::
object_t
::
process_attach
(
i_engine
*
engine_
,
unsigned
char
peer_identity_size_
,
unsigned
char
*
peer_identity_
)
{
{
zmq_assert
(
false
);
zmq_assert
(
false
);
}
}
...
...
src/object.hpp
View file @
2e78e485
...
@@ -64,7 +64,8 @@ namespace zmq
...
@@ -64,7 +64,8 @@ namespace zmq
void
send_own
(
class
socket_base_t
*
destination_
,
void
send_own
(
class
socket_base_t
*
destination_
,
class
owned_t
*
object_
);
class
owned_t
*
object_
);
void
send_attach
(
class
session_t
*
destination_
,
void
send_attach
(
class
session_t
*
destination_
,
struct
i_engine
*
engine_
,
bool
inc_seqnum_
=
true
);
struct
i_engine
*
engine_
,
unsigned
char
peer_identity_size_
,
unsigned
char
*
peer_identity_
,
bool
inc_seqnum_
=
true
);
void
send_bind
(
class
socket_base_t
*
destination_
,
void
send_bind
(
class
socket_base_t
*
destination_
,
class
reader_t
*
in_pipe_
,
class
writer_t
*
out_pipe_
,
class
reader_t
*
in_pipe_
,
class
writer_t
*
out_pipe_
,
bool
inc_seqnum_
=
true
);
bool
inc_seqnum_
=
true
);
...
@@ -81,7 +82,8 @@ namespace zmq
...
@@ -81,7 +82,8 @@ namespace zmq
virtual
void
process_stop
();
virtual
void
process_stop
();
virtual
void
process_plug
();
virtual
void
process_plug
();
virtual
void
process_own
(
class
owned_t
*
object_
);
virtual
void
process_own
(
class
owned_t
*
object_
);
virtual
void
process_attach
(
struct
i_engine
*
engine_
);
virtual
void
process_attach
(
struct
i_engine
*
engine_
,
unsigned
char
peer_identity_size_
,
unsigned
char
*
peer_identity_
);
virtual
void
process_bind
(
class
reader_t
*
in_pipe_
,
virtual
void
process_bind
(
class
reader_t
*
in_pipe_
,
class
writer_t
*
out_pipe_
);
class
writer_t
*
out_pipe_
);
virtual
void
process_revive
();
virtual
void
process_revive
();
...
...
src/session.cpp
View file @
2e78e485
...
@@ -232,7 +232,8 @@ void zmq::session_t::process_unplug ()
...
@@ -232,7 +232,8 @@ void zmq::session_t::process_unplug ()
}
}
}
}
void
zmq
::
session_t
::
process_attach
(
i_engine
*
engine_
)
void
zmq
::
session_t
::
process_attach
(
i_engine
*
engine_
,
unsigned
char
peer_identity_size_
,
unsigned
char
*
peer_identity_
)
{
{
zmq_assert
(
!
engine
);
zmq_assert
(
!
engine
);
zmq_assert
(
engine_
);
zmq_assert
(
engine_
);
...
...
src/session.hpp
View file @
2e78e485
...
@@ -66,7 +66,8 @@ namespace zmq
...
@@ -66,7 +66,8 @@ namespace zmq
// Handlers for incoming commands.
// Handlers for incoming commands.
void
process_plug
();
void
process_plug
();
void
process_unplug
();
void
process_unplug
();
void
process_attach
(
struct
i_engine
*
engine_
);
void
process_attach
(
struct
i_engine
*
engine_
,
unsigned
char
peer_identity_size_
,
unsigned
char
*
peer_identity_
);
// Inbound pipe, i.e. one the session is getting messages from.
// Inbound pipe, i.e. one the session is getting messages from.
class
reader_t
*
in_pipe
;
class
reader_t
*
in_pipe
;
...
...
src/zmq_init.cpp
View file @
2e78e485
...
@@ -192,7 +192,8 @@ void zmq::zmq_init_t::finalise ()
...
@@ -192,7 +192,8 @@ void zmq::zmq_init_t::finalise ()
}
}
// No need to increment seqnum as it was laready incremented above.
// No need to increment seqnum as it was laready incremented above.
send_attach
(
session
,
engine
,
false
);
send_attach
(
session
,
engine
,
(
unsigned
char
)
peer_identity
.
size
(),
(
unsigned
char
*
)
peer_identity
.
data
(),
false
);
// Destroy the init object.
// Destroy the init object.
engine
=
NULL
;
engine
=
NULL
;
...
...
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