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
2dd50165
Commit
2dd50165
authored
Aug 27, 2009
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multiple bugs fixed
parent
67194267
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
61 additions
and
15 deletions
+61
-15
i_inout.hpp
src/i_inout.hpp
+8
-0
pipe.hpp
src/pipe.hpp
+2
-1
session.cpp
src/session.cpp
+12
-1
session.hpp
src/session.hpp
+1
-0
zmq_connecter_init.cpp
src/zmq_connecter_init.cpp
+6
-0
zmq_connecter_init.hpp
src/zmq_connecter_init.hpp
+1
-0
zmq_encoder.cpp
src/zmq_encoder.cpp
+0
-1
zmq_engine.cpp
src/zmq_engine.cpp
+4
-1
zmq_listener_init.cpp
src/zmq_listener_init.cpp
+22
-11
zmq_listener_init.hpp
src/zmq_listener_init.hpp
+5
-0
No files found.
src/i_inout.hpp
View file @
2dd50165
...
@@ -27,9 +27,17 @@ namespace zmq
...
@@ -27,9 +27,17 @@ namespace zmq
struct
i_inout
struct
i_inout
{
{
// Engine asks to get a message to send to the network.
virtual
bool
read
(
::
zmq_msg_t
*
msg_
)
=
0
;
virtual
bool
read
(
::
zmq_msg_t
*
msg_
)
=
0
;
// Engine sends the incoming message further on downstream.
virtual
bool
write
(
::
zmq_msg_t
*
msg_
)
=
0
;
virtual
bool
write
(
::
zmq_msg_t
*
msg_
)
=
0
;
// Flush all the previously written messages downstream.
virtual
void
flush
()
=
0
;
virtual
void
flush
()
=
0
;
// Drop all the references to the engine.
virtual
void
detach
()
=
0
;
};
};
}
}
...
...
src/pipe.hpp
View file @
2dd50165
...
@@ -42,8 +42,9 @@ namespace zmq
...
@@ -42,8 +42,9 @@ namespace zmq
// Reads a message to the underlying pipe.
// Reads a message to the underlying pipe.
bool
read
(
struct
zmq_msg_t
*
msg_
);
bool
read
(
struct
zmq_msg_t
*
msg_
);
// Mnaipulation of index of the pipe.
void
set_endpoint
(
i_endpoint
*
endpoint_
);
void
set_endpoint
(
i_endpoint
*
endpoint_
);
// Mnaipulation of index of the pipe.
void
set_index
(
int
index_
);
void
set_index
(
int
index_
);
int
get_index
();
int
get_index
();
...
...
src/session.cpp
View file @
2dd50165
...
@@ -26,7 +26,7 @@ zmq::session_t::session_t (object_t *parent_, socket_base_t *owner_,
...
@@ -26,7 +26,7 @@ zmq::session_t::session_t (object_t *parent_, socket_base_t *owner_,
const
char
*
name_
,
const
options_t
&
options_
)
:
const
char
*
name_
,
const
options_t
&
options_
)
:
owned_t
(
parent_
,
owner_
),
owned_t
(
parent_
,
owner_
),
in_pipe
(
NULL
),
in_pipe
(
NULL
),
active
(
fals
e
),
active
(
tru
e
),
out_pipe
(
NULL
),
out_pipe
(
NULL
),
engine
(
NULL
),
engine
(
NULL
),
name
(
name_
),
name
(
name_
),
...
@@ -74,6 +74,16 @@ void zmq::session_t::flush ()
...
@@ -74,6 +74,16 @@ void zmq::session_t::flush ()
out_pipe
->
flush
();
out_pipe
->
flush
();
}
}
void
zmq
::
session_t
::
detach
()
{
// Engine is terminating itself.
engine
=
NULL
;
// TODO: In the case od anonymous connection, terminate the session.
// if (anonymous)
// term ();
}
void
zmq
::
session_t
::
revive
(
reader_t
*
pipe_
)
void
zmq
::
session_t
::
revive
(
reader_t
*
pipe_
)
{
{
zmq_assert
(
in_pipe
==
pipe_
);
zmq_assert
(
in_pipe
==
pipe_
);
...
@@ -98,6 +108,7 @@ void zmq::session_t::process_plug ()
...
@@ -98,6 +108,7 @@ void zmq::session_t::process_plug ()
pipe_t
*
inbound
=
new
pipe_t
(
this
,
owner
,
options
.
hwm
,
options
.
lwm
);
pipe_t
*
inbound
=
new
pipe_t
(
this
,
owner
,
options
.
hwm
,
options
.
lwm
);
zmq_assert
(
inbound
);
zmq_assert
(
inbound
);
in_pipe
=
&
inbound
->
reader
;
in_pipe
=
&
inbound
->
reader
;
in_pipe
->
set_endpoint
(
this
);
pipe_t
*
outbound
=
new
pipe_t
(
owner
,
this
,
options
.
hwm
,
options
.
lwm
);
pipe_t
*
outbound
=
new
pipe_t
(
owner
,
this
,
options
.
hwm
,
options
.
lwm
);
zmq_assert
(
outbound
);
zmq_assert
(
outbound
);
out_pipe
=
&
outbound
->
writer
;
out_pipe
=
&
outbound
->
writer
;
...
...
src/session.hpp
View file @
2dd50165
...
@@ -48,6 +48,7 @@ namespace zmq
...
@@ -48,6 +48,7 @@ namespace zmq
bool
read
(
::
zmq_msg_t
*
msg_
);
bool
read
(
::
zmq_msg_t
*
msg_
);
bool
write
(
::
zmq_msg_t
*
msg_
);
bool
write
(
::
zmq_msg_t
*
msg_
);
void
flush
();
void
flush
();
void
detach
();
// i_endpoint interface implementation.
// i_endpoint interface implementation.
void
revive
(
class
reader_t
*
pipe_
);
void
revive
(
class
reader_t
*
pipe_
);
...
...
src/zmq_connecter_init.cpp
View file @
2dd50165
...
@@ -80,6 +80,12 @@ void zmq::zmq_connecter_init_t::flush ()
...
@@ -80,6 +80,12 @@ void zmq::zmq_connecter_init_t::flush ()
zmq_assert
(
false
);
zmq_assert
(
false
);
}
}
void
zmq
::
zmq_connecter_init_t
::
detach
()
{
// TODO: Engine is closing down. Init object is to be closed as well.
zmq_assert
(
false
);
}
void
zmq
::
zmq_connecter_init_t
::
process_plug
()
void
zmq
::
zmq_connecter_init_t
::
process_plug
()
{
{
zmq_assert
(
engine
);
zmq_assert
(
engine
);
...
...
src/zmq_connecter_init.hpp
View file @
2dd50165
...
@@ -49,6 +49,7 @@ namespace zmq
...
@@ -49,6 +49,7 @@ namespace zmq
bool
read
(
::
zmq_msg_t
*
msg_
);
bool
read
(
::
zmq_msg_t
*
msg_
);
bool
write
(
::
zmq_msg_t
*
msg_
);
bool
write
(
::
zmq_msg_t
*
msg_
);
void
flush
();
void
flush
();
void
detach
();
// Handlers for incoming commands.
// Handlers for incoming commands.
void
process_plug
();
void
process_plug
();
...
...
src/zmq_encoder.cpp
View file @
2dd50165
...
@@ -73,4 +73,3 @@ bool zmq::zmq_encoder_t::message_ready ()
...
@@ -73,4 +73,3 @@ bool zmq::zmq_encoder_t::message_ready ()
}
}
return
true
;
return
true
;
}
}
src/zmq_engine.cpp
View file @
2dd50165
...
@@ -136,5 +136,8 @@ void zmq::zmq_engine_t::revive ()
...
@@ -136,5 +136,8 @@ void zmq::zmq_engine_t::revive ()
void
zmq
::
zmq_engine_t
::
error
()
void
zmq
::
zmq_engine_t
::
error
()
{
{
zmq_assert
(
false
);
zmq_assert
(
inout
);
inout
->
detach
();
unplug
();
delete
this
;
}
}
src/zmq_listener_init.cpp
View file @
2dd50165
...
@@ -17,8 +17,6 @@
...
@@ -17,8 +17,6 @@
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>
#include "zmq_listener_init.hpp"
#include "zmq_listener_init.hpp"
#include "io_thread.hpp"
#include "io_thread.hpp"
#include "session.hpp"
#include "session.hpp"
...
@@ -27,7 +25,8 @@
...
@@ -27,7 +25,8 @@
zmq
::
zmq_listener_init_t
::
zmq_listener_init_t
(
io_thread_t
*
parent_
,
zmq
::
zmq_listener_init_t
::
zmq_listener_init_t
(
io_thread_t
*
parent_
,
socket_base_t
*
owner_
,
fd_t
fd_
,
const
options_t
&
options_
)
:
socket_base_t
*
owner_
,
fd_t
fd_
,
const
options_t
&
options_
)
:
owned_t
(
parent_
,
owner_
),
owned_t
(
parent_
,
owner_
),
options
(
options_
)
options
(
options_
),
has_peer_identity
(
false
)
{
{
// Create associated engine object.
// Create associated engine object.
engine
=
new
zmq_engine_t
(
parent_
,
fd_
);
engine
=
new
zmq_engine_t
(
parent_
,
fd_
);
...
@@ -47,19 +46,33 @@ bool zmq::zmq_listener_init_t::read (::zmq_msg_t *msg_)
...
@@ -47,19 +46,33 @@ bool zmq::zmq_listener_init_t::read (::zmq_msg_t *msg_)
bool
zmq
::
zmq_listener_init_t
::
write
(
::
zmq_msg_t
*
msg_
)
bool
zmq
::
zmq_listener_init_t
::
write
(
::
zmq_msg_t
*
msg_
)
{
{
// Once we've got peer's identity we aren't interested in subsequent
// messages.
if
(
has_peer_identity
)
return
false
;
// Retreieve the remote identity. We'll use it as a local session name.
// Retreieve the remote identity. We'll use it as a local session name.
std
::
string
session_name
=
std
::
string
((
const
char
*
)
zmq_msg_data
(
msg_
),
has_peer_identity
=
true
;
peer_identity
.
assign
((
const
char
*
)
zmq_msg_data
(
msg_
),
zmq_msg_size
(
msg_
));
zmq_msg_size
(
msg_
));
return
true
;
}
void
zmq
::
zmq_listener_init_t
::
flush
()
{
zmq_assert
(
has_peer_identity
);
// Initialisation is done. Disconnect the engine from the init object.
// Initialisation is done. Disconnect the engine from the init object.
engine
->
unplug
();
engine
->
unplug
();
// Have a look whether the session already exists. If it does, attach it
// Have a look whether the session already exists. If it does, attach it
// to the engine. If it doesn't create it first.
// to the engine. If it doesn't create it first.
session_t
*
session
=
owner
->
find_session
(
session_name
.
c_str
());
session_t
*
session
=
owner
->
find_session
(
peer_identity
.
c_str
());
if
(
!
session
)
{
if
(
!
session
)
{
io_thread_t
*
io_thread
=
choose_io_thread
(
options
.
affinity
);
io_thread_t
*
io_thread
=
choose_io_thread
(
options
.
affinity
);
session
=
new
session_t
(
io_thread
,
owner
,
session_name
.
c_str
(),
session
=
new
session_t
(
io_thread
,
owner
,
peer_identity
.
c_str
(),
options
);
options
);
zmq_assert
(
session
);
zmq_assert
(
session
);
send_plug
(
session
);
send_plug
(
session
);
...
@@ -73,14 +86,12 @@ bool zmq::zmq_listener_init_t::write (::zmq_msg_t *msg_)
...
@@ -73,14 +86,12 @@ bool zmq::zmq_listener_init_t::write (::zmq_msg_t *msg_)
// Destroy the init object.
// Destroy the init object.
term
();
term
();
return
true
;
}
}
void
zmq
::
zmq_listener_init_t
::
flus
h
()
void
zmq
::
zmq_listener_init_t
::
detac
h
()
{
{
//
No need to do anything. zmq_listener_init_t does no batching
//
TODO: Engine is closing down. Init object is to be closed as well.
// of messages. Each message is processed immediately on write.
zmq_assert
(
false
);
}
}
void
zmq
::
zmq_listener_init_t
::
process_plug
()
void
zmq
::
zmq_listener_init_t
::
process_plug
()
...
...
src/zmq_listener_init.hpp
View file @
2dd50165
...
@@ -49,6 +49,7 @@ namespace zmq
...
@@ -49,6 +49,7 @@ namespace zmq
bool
read
(
::
zmq_msg_t
*
msg_
);
bool
read
(
::
zmq_msg_t
*
msg_
);
bool
write
(
::
zmq_msg_t
*
msg_
);
bool
write
(
::
zmq_msg_t
*
msg_
);
void
flush
();
void
flush
();
void
detach
();
// Handlers for incoming commands.
// Handlers for incoming commands.
void
process_plug
();
void
process_plug
();
...
@@ -62,6 +63,10 @@ namespace zmq
...
@@ -62,6 +63,10 @@ namespace zmq
// Associated socket options.
// Associated socket options.
options_t
options
;
options_t
options
;
// Indetity on the other end of the connection.
bool
has_peer_identity
;
std
::
string
peer_identity
;
zmq_listener_init_t
(
const
zmq_listener_init_t
&
);
zmq_listener_init_t
(
const
zmq_listener_init_t
&
);
void
operator
=
(
const
zmq_listener_init_t
&
);
void
operator
=
(
const
zmq_listener_init_t
&
);
};
};
...
...
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