Permalink
Browse files

Dead code removed from named_session.cpp

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
  • Loading branch information...
1 parent f987f4b commit 7045a4a21327f19170e282f6ba2d25caff13aa90 @sustrik sustrik committed Mar 15, 2011
Showing with 18 additions and 44 deletions.
  1. +16 −41 src/named_session.cpp
  2. +2 −3 src/named_session.hpp
View
@@ -23,63 +23,38 @@
zmq::named_session_t::named_session_t (class io_thread_t *io_thread_,
socket_base_t *socket_, const options_t &options_,
- const blob_t &name_) :
+ const blob_t &peer_identity_) :
session_t (io_thread_, socket_, options_),
- name (name_)
+ peer_identity (peer_identity_)
{
- // Make double sure that the session has valid name.
- zmq_assert (!name.empty ());
- zmq_assert (name [0] != 0);
+ // Make double sure that the peer's identity is not transient.
+ zmq_assert (!peer_identity.empty ());
+ zmq_assert (peer_identity [0] != 0);
- if (!socket_->register_session (name, this)) {
+ bool ok = socket_->register_session (peer_identity, this);
- // TODO: There's already a session with the specified
- // identity. We should log the error and drop the
- // session.
- zmq_assert (false);
- }
+ // If new session is being created, the caller should have already
+ // checked that the session for specified identity doesn't exist yet.
+ // Thus, register_session should not fail.
+ zmq_assert (ok);
}
zmq::named_session_t::~named_session_t ()
{
// Unregister the session from the global list of named sessions.
- if (!name.empty ())
- unregister_session (name);
+ unregister_session (peer_identity);
}
void zmq::named_session_t::attached (const blob_t &peer_identity_)
{
- if (!name.empty ()) {
-
- // If both IDs are temporary, no checking is needed.
- // TODO: Old ID should be reused in this case...
- if (name.empty () || name [0] != 0 ||
- peer_identity_.empty () || peer_identity_ [0] != 0) {
-
- // If we already know the peer name do nothing, just check whether
- // it haven't changed.
- zmq_assert (name == peer_identity_);
- }
- }
- else if (!peer_identity_.empty ()) {
-
- // Store the peer identity.
- name = peer_identity_;
-
- // Register the session using the peer name.
- if (!register_session (name, this)) {
-
- // TODO: There's already a session with the specified
- // identity. We should presumably syslog it and drop the
- // session.
- zmq_assert (false);
- }
- }
+ // The owner should take care to not attach the session
+ // to an unrelated peer.
+ zmq_assert (peer_identity == peer_identity_);
}
void zmq::named_session_t::detached ()
{
- // Do nothing. Named sessions are never destroyed because of disconnection,
- // neither they have to actively reconnect.
+ // Do nothing. Named sessions are never destroyed because of disconnection.
+ // Neither they have to actively reconnect.
}
View
@@ -36,7 +36,7 @@ namespace zmq
named_session_t (class io_thread_t *io_thread_,
class socket_base_t *socket_, const options_t &options_,
- const blob_t &name_);
+ const blob_t &peer_identity_);
~named_session_t ();
// Handlers for events from session base class.
@@ -45,8 +45,7 @@ namespace zmq
private:
- // Name of the session. Corresponds to the peer's strong identity.
- blob_t name;
+ blob_t peer_identity;
named_session_t (const named_session_t&);
const named_session_t &operator = (const named_session_t&);

0 comments on commit 7045a4a

Please sign in to comment.