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
9b8993ef
Commit
9b8993ef
authored
Aug 24, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
elementary fixes to the named session
parent
46d70555
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
55 deletions
+37
-55
named_session.cpp
src/named_session.cpp
+11
-10
session.cpp
src/session.cpp
+11
-26
session.hpp
src/session.hpp
+4
-5
socket_base.cpp
src/socket_base.cpp
+6
-6
socket_base.hpp
src/socket_base.hpp
+3
-4
zmq_init.cpp
src/zmq_init.cpp
+2
-4
No files found.
src/named_session.cpp
View file @
9b8993ef
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
#include "named_session.hpp"
#include "named_session.hpp"
#include "socket_base.hpp"
#include "socket_base.hpp"
/*
zmq
::
named_session_t
::
named_session_t
(
class
io_thread_t
*
io_thread_
,
zmq
::
named_session_t
::
named_session_t
(
class
io_thread_t
*
io_thread_
,
socket_base_t
*
socket_
,
const
options_t
&
options_
,
socket_base_t
*
socket_
,
const
options_t
&
options_
,
const
blob_t
&
name_
)
:
const
blob_t
&
name_
)
:
...
@@ -46,31 +45,33 @@ zmq::named_session_t::~named_session_t ()
...
@@ -46,31 +45,33 @@ zmq::named_session_t::~named_session_t ()
void
zmq
::
named_session_t
::
detach
()
void
zmq
::
named_session_t
::
detach
()
{
{
// TODO:
// Clean up the mess left over by the failed connection.
zmq_assert (false);
clean_pipes
();
// Do nothing. Wait till the connection comes up again.
}
}
void
zmq
::
named_session_t
::
attached
(
const
blob_t
&
peer_identity_
)
void
zmq
::
named_session_t
::
attached
(
const
blob_t
&
peer_identity_
)
{
{
if (!
peer_identity
.empty ()) {
if
(
!
name
.
empty
())
{
// If both IDs are temporary, no checking is needed.
// If both IDs are temporary, no checking is needed.
// TODO: Old ID should be reused in this case...
// TODO: Old ID should be reused in this case...
if (
peer_identity.empty () || peer_identity
[0] != 0 ||
if
(
name
.
empty
()
||
name
[
0
]
!=
0
||
peer_identity_
.
empty
()
||
peer_identity_
[
0
]
!=
0
)
{
peer_identity_
.
empty
()
||
peer_identity_
[
0
]
!=
0
)
{
// If we already know the peer name do nothing, just check whether
// If we already know the peer name do nothing, just check whether
// it haven't changed.
// it haven't changed.
zmq_assert (
peer_identity
== peer_identity_);
zmq_assert
(
name
==
peer_identity_
);
}
}
}
}
else
if
(
!
peer_identity_
.
empty
())
{
else
if
(
!
peer_identity_
.
empty
())
{
// Store the peer identity.
// Store the peer identity.
peer_identity
= peer_identity_;
name
=
peer_identity_
;
// Register the session using the peer name.
// Register the session using the peer name.
if (!register_session (
peer_identity
, this)) {
if
(
!
register_session
(
name
,
this
))
{
// TODO: There's already a session with the specified
// TODO: There's already a session with the specified
// identity. We should presumably syslog it and drop the
// identity. We should presumably syslog it and drop the
...
@@ -82,6 +83,6 @@ void zmq::named_session_t::attached (const blob_t &peer_identity_)
...
@@ -82,6 +83,6 @@ void zmq::named_session_t::attached (const blob_t &peer_identity_)
void
zmq
::
named_session_t
::
detached
()
void
zmq
::
named_session_t
::
detached
()
{
{
socket->unregister_session (peer_identity
);
unregister_session
(
name
);
}
}
*/
src/session.cpp
View file @
9b8993ef
...
@@ -163,31 +163,6 @@ void zmq::session_t::process_plug ()
...
@@ -163,31 +163,6 @@ void zmq::session_t::process_plug ()
{
{
}
}
void
zmq
::
session_t
::
process_unplug
()
{
// TODO: There may be a problem here. The called ensures that all the
// commands on the fly have been delivered. However, given that the
// session is unregistered from the global repository only at this point
// there may be some commands being sent to the session right now.
// Unregister the session from the socket.
// if (!peer_identity.empty () && peer_identity [0] != 0)
// unregister_session (peer_identity);
// TODO: Should be done in named session.
// Ask associated pipes to terminate.
if
(
in_pipe
)
in_pipe
->
terminate
();
if
(
out_pipe
)
out_pipe
->
terminate
();
if
(
engine
)
{
engine
->
unplug
();
delete
engine
;
engine
=
NULL
;
}
}
void
zmq
::
session_t
::
finalise
()
void
zmq
::
session_t
::
finalise
()
{
{
// If all conditions are met, proceed with termination:
// If all conditions are met, proceed with termination:
...
@@ -221,7 +196,7 @@ void zmq::session_t::process_attach (i_engine *engine_,
...
@@ -221,7 +196,7 @@ void zmq::session_t::process_attach (i_engine *engine_,
}
}
if
(
socket_reader
||
socket_writer
)
if
(
socket_reader
||
socket_writer
)
send_bind
(
socket
,
socket_reader
,
socket_writer
,
peer_identity
);
send_bind
(
socket
,
socket_reader
,
socket_writer
,
peer_identity
_
);
// Plug in the engine.
// Plug in the engine.
zmq_assert
(
!
engine
);
zmq_assert
(
!
engine
);
...
@@ -252,6 +227,16 @@ void zmq::session_t::process_term ()
...
@@ -252,6 +227,16 @@ void zmq::session_t::process_term ()
finalise
();
finalise
();
}
}
bool
zmq
::
session_t
::
register_session
(
const
blob_t
&
name_
,
session_t
*
session_
)
{
return
socket
->
register_session
(
name_
,
session_
);
}
void
zmq
::
session_t
::
unregister_session
(
const
blob_t
&
name_
)
{
socket
->
unregister_session
(
name_
);
}
void
zmq
::
session_t
::
attached
(
const
blob_t
&
peer_identity_
)
void
zmq
::
session_t
::
attached
(
const
blob_t
&
peer_identity_
)
{
{
}
}
...
...
src/session.hpp
View file @
9b8993ef
...
@@ -72,6 +72,10 @@ namespace zmq
...
@@ -72,6 +72,10 @@ namespace zmq
virtual
void
attached
(
const
blob_t
&
peer_identity_
);
virtual
void
attached
(
const
blob_t
&
peer_identity_
);
virtual
void
detached
();
virtual
void
detached
();
// Allows derives session types to (un)register session names.
bool
register_session
(
const
blob_t
&
name_
,
class
session_t
*
session_
);
void
unregister_session
(
const
blob_t
&
name_
);
~
session_t
();
~
session_t
();
// Remove any half processed messages. Flush unflushed messages.
// Remove any half processed messages. Flush unflushed messages.
...
@@ -85,7 +89,6 @@ namespace zmq
...
@@ -85,7 +89,6 @@ namespace zmq
// Handlers for incoming commands.
// Handlers for incoming commands.
void
process_plug
();
void
process_plug
();
void
process_unplug
();
void
process_attach
(
struct
i_engine
*
engine_
,
void
process_attach
(
struct
i_engine
*
engine_
,
const
blob_t
&
peer_identity_
);
const
blob_t
&
peer_identity_
);
void
process_term
();
void
process_term
();
...
@@ -110,10 +113,6 @@ namespace zmq
...
@@ -110,10 +113,6 @@ namespace zmq
// The protocol I/O engine connected to the session.
// The protocol I/O engine connected to the session.
struct
i_engine
*
engine
;
struct
i_engine
*
engine
;
// Identity of the peer (say the component on the other side
// of TCP connection).
blob_t
peer_identity
;
// The socket the session belongs to.
// The socket the session belongs to.
class
socket_base_t
*
socket
;
class
socket_base_t
*
socket
;
...
...
src/socket_base.cpp
View file @
9b8993ef
...
@@ -564,29 +564,29 @@ bool zmq::socket_base_t::has_out ()
...
@@ -564,29 +564,29 @@ bool zmq::socket_base_t::has_out ()
return
xhas_out
();
return
xhas_out
();
}
}
bool
zmq
::
socket_base_t
::
register_session
(
const
blob_t
&
peer_identity
_
,
bool
zmq
::
socket_base_t
::
register_session
(
const
blob_t
&
name
_
,
session_t
*
session_
)
session_t
*
session_
)
{
{
sessions_sync
.
lock
();
sessions_sync
.
lock
();
bool
registered
=
sessions
.
insert
(
bool
registered
=
sessions
.
insert
(
std
::
make_pair
(
peer_identity
_
,
session_
)).
second
;
std
::
make_pair
(
name
_
,
session_
)).
second
;
sessions_sync
.
unlock
();
sessions_sync
.
unlock
();
return
registered
;
return
registered
;
}
}
void
zmq
::
socket_base_t
::
unregister_session
(
const
blob_t
&
peer_identity
_
)
void
zmq
::
socket_base_t
::
unregister_session
(
const
blob_t
&
name
_
)
{
{
sessions_sync
.
lock
();
sessions_sync
.
lock
();
sessions_t
::
iterator
it
=
sessions
.
find
(
peer_identity
_
);
sessions_t
::
iterator
it
=
sessions
.
find
(
name
_
);
zmq_assert
(
it
!=
sessions
.
end
());
zmq_assert
(
it
!=
sessions
.
end
());
sessions
.
erase
(
it
);
sessions
.
erase
(
it
);
sessions_sync
.
unlock
();
sessions_sync
.
unlock
();
}
}
zmq
::
session_t
*
zmq
::
socket_base_t
::
find_session
(
const
blob_t
&
peer_identity
_
)
zmq
::
session_t
*
zmq
::
socket_base_t
::
find_session
(
const
blob_t
&
name
_
)
{
{
sessions_sync
.
lock
();
sessions_sync
.
lock
();
sessions_t
::
iterator
it
=
sessions
.
find
(
peer_identity
_
);
sessions_t
::
iterator
it
=
sessions
.
find
(
name
_
);
if
(
it
==
sessions
.
end
())
{
if
(
it
==
sessions
.
end
())
{
sessions_sync
.
unlock
();
sessions_sync
.
unlock
();
return
NULL
;
return
NULL
;
...
...
src/socket_base.hpp
View file @
9b8993ef
...
@@ -71,10 +71,9 @@ namespace zmq
...
@@ -71,10 +71,9 @@ namespace zmq
bool
has_out
();
bool
has_out
();
// Registry of named sessions.
// Registry of named sessions.
bool
register_session
(
const
blob_t
&
peer_identity_
,
bool
register_session
(
const
blob_t
&
name_
,
class
session_t
*
session_
);
class
session_t
*
session_
);
void
unregister_session
(
const
blob_t
&
name_
);
void
unregister_session
(
const
blob_t
&
peer_identity_
);
class
session_t
*
find_session
(
const
blob_t
&
name_
);
class
session_t
*
find_session
(
const
blob_t
&
peer_identity_
);
// i_reader_events interface implementation.
// i_reader_events interface implementation.
void
activated
(
class
reader_t
*
pipe_
);
void
activated
(
class
reader_t
*
pipe_
);
...
...
src/zmq_init.cpp
View file @
9b8993ef
...
@@ -180,10 +180,8 @@ void zmq::zmq_init_t::finalise_initialisation ()
...
@@ -180,10 +180,8 @@ void zmq::zmq_init_t::finalise_initialisation ()
}
}
// There's no such named session. We have to create one.
// There's no such named session. We have to create one.
// TODO:
session
=
new
(
std
::
nothrow
)
named_session_t
(
io_thread
,
socket
,
zmq_assert
(
false
);
options
,
peer_identity
);
// session = new (std::nothrow) named_session_t (io_thread, socket,
// options, peer_identity);
zmq_assert
(
session
);
zmq_assert
(
session
);
launch_sibling
(
session
);
launch_sibling
(
session
);
engine
->
unplug
();
engine
->
unplug
();
...
...
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