Permalink
Browse files

Fix issue #370

The patch extends the internal session's API with the reset method.
This method is used to reset a session's state so that it can
handle a new connection.
  • Loading branch information...
1 parent f7bd543 commit 7fe45af30f5978e490575b0c088cf7b444c98e9f @hurtonm hurtonm committed May 29, 2012
Showing with 15 additions and 3 deletions.
  1. +5 −0 src/req.cpp
  2. +1 −0 src/req.hpp
  3. +8 −3 src/session_base.cpp
  4. +1 −0 src/session_base.hpp
View
@@ -178,3 +178,8 @@ int zmq::req_session_t::write (msg_t *msg_)
return -1;
}
+void zmq::req_session_t::reset ()
+{
+ session_base_t::reset ();
+ state = identity;
+}
View
@@ -72,6 +72,7 @@ namespace zmq
// Overloads of the functions from session_base_t.
int write (msg_t *msg_);
+ void reset ();
private:
View
@@ -190,6 +190,13 @@ int zmq::session_base_t::write (msg_t *msg_)
return -1;
}
+void zmq::session_base_t::reset ()
+{
+ // Restore identity flags.
+ send_identity = options.send_identity;
+ recv_identity = options.recv_identity;
+}
+
void zmq::session_base_t::flush ()
{
if (pipe)
@@ -388,9 +395,7 @@ void zmq::session_base_t::detached ()
return;
}
- // Restore identity flags.
- send_identity = options.send_identity;
- recv_identity = options.recv_identity;
+ reset ();
// Reconnect.
if (options.reconnect_ivl != -1)
View
@@ -56,6 +56,7 @@ namespace zmq
// Following functions are the interface exposed towards the engine.
virtual int read (msg_t *msg_);
virtual int write (msg_t *msg_);
+ virtual void reset ();
void flush ();
void detach ();

0 comments on commit 7fe45af

Please sign in to comment.