summaryrefslogtreecommitdiff
path: root/src/session.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-03-16 13:26:23 +0100
committerMartin Sustrik <sustrik@250bpm.com>2011-03-16 13:26:23 +0100
commit32ded2b457b2102dba4c15e00363f031d212b1c4 (patch)
tree163f0540f5f26277ba934bc80671a7c4fc73b7ad /src/session.cpp
parentb79d07b8bc844135c44c1ff8b84b50dc08f56925 (diff)
Duplicate identities now checked with zmq_connect
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/session.cpp')
-rw-r--r--src/session.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/session.cpp b/src/session.cpp
index 33c25d9..3ba971f 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -214,26 +214,25 @@ void zmq::session_t::process_plug ()
void zmq::session_t::process_attach (i_engine *engine_,
const blob_t &peer_identity_)
{
- // If some other object (e.g. init) notifies us that the connection failed
- // we need to start the reconnection process.
- if (!engine_) {
- zmq_assert (!engine);
- detached ();
- return;
- }
-
// If we are already terminating, we destroy the engine straight away.
// Note that we don't have to unplug it before deleting as it's not
// yet plugged to the session.
if (state == terminating) {
- delete engine_;
+ if (engine_)
+ delete engine_;
return;
}
- // If the session already has an engine attached, destroy new one.
- // Note new engine is not plugged in yet, we don't have to unplug it.
- if (engine) {
- log ("DPID: duplicate peer identity - disconnecting peer");
+ // If some other object (e.g. init) notifies us that the connection failed
+ // without creating an engine we need to start the reconnection process.
+ if (!engine_) {
+ zmq_assert (!engine);
+ detached ();
+ return;
+ }
+
+ // Trigger the notfication event about the attachment.
+ if (!attached (peer_identity_)) {
delete engine_;
return;
}
@@ -248,8 +247,8 @@ void zmq::session_t::process_attach (i_engine *engine_,
// Create the pipes, as required.
if (options.requires_in) {
- create_pipe (socket, this, options.hwm, options.swap, &socket_reader,
- &out_pipe);
+ create_pipe (socket, this, options.hwm, options.swap,
+ &socket_reader, &out_pipe);
out_pipe->set_event_sink (this);
}
if (options.requires_out) {
@@ -264,11 +263,9 @@ void zmq::session_t::process_attach (i_engine *engine_,
}
// Plug in the engine.
+ zmq_assert (!engine);
engine = engine_;
engine->plug (io_thread, this);
-
- // Trigger the notfication about the attachment.
- attached (peer_identity_);
}
void zmq::session_t::detach ()
@@ -330,6 +327,11 @@ void zmq::session_t::timer_event (int id_)
proceed_with_term ();
}
+bool zmq::session_t::has_engine ()
+{
+ return engine != NULL;
+}
+
bool zmq::session_t::register_session (const blob_t &name_, session_t *session_)
{
return socket->register_session (name_, session_);