Skip to content

Commit

Permalink
Fix issue #370
Browse files Browse the repository at this point in the history
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
hurtonm committed May 29, 2012
1 parent f7bd543 commit 7fe45af
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/req.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -178,3 +178,8 @@ int zmq::req_session_t::write (msg_t *msg_)
return -1; return -1;
} }


void zmq::req_session_t::reset ()
{
session_base_t::reset ();
state = identity;
}
1 change: 1 addition & 0 deletions src/req.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ namespace zmq


// Overloads of the functions from session_base_t. // Overloads of the functions from session_base_t.
int write (msg_t *msg_); int write (msg_t *msg_);
void reset ();


private: private:


Expand Down
11 changes: 8 additions & 3 deletions src/session_base.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ int zmq::session_base_t::write (msg_t *msg_)
return -1; 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 () void zmq::session_base_t::flush ()
{ {
if (pipe) if (pipe)
Expand Down Expand Up @@ -388,9 +395,7 @@ void zmq::session_base_t::detached ()
return; return;
} }


// Restore identity flags. reset ();
send_identity = options.send_identity;
recv_identity = options.recv_identity;


// Reconnect. // Reconnect.
if (options.reconnect_ivl != -1) if (options.reconnect_ivl != -1)
Expand Down
1 change: 1 addition & 0 deletions src/session_base.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace zmq
// Following functions are the interface exposed towards the engine. // Following functions are the interface exposed towards the engine.
virtual int read (msg_t *msg_); virtual int read (msg_t *msg_);
virtual int write (msg_t *msg_); virtual int write (msg_t *msg_);
virtual void reset ();
void flush (); void flush ();
void detach (); void detach ();


Expand Down

0 comments on commit 7fe45af

Please sign in to comment.