Commit f5c59556 authored by Christian Kamm's avatar Christian Kamm

REQ: Unset reply_pipe if it terminates.

* Fixes a terminate() call on a dangling pointer in the SEND_RESETS
  case.
* Fixes recv_reply_pipe() never receiving a message once the pipe it is
  waiting on is terminated.
parent a0cc87a9
...@@ -193,7 +193,7 @@ bool zmq::req_t::xhas_out () ...@@ -193,7 +193,7 @@ bool zmq::req_t::xhas_out ()
return dealer_t::xhas_out (); return dealer_t::xhas_out ();
} }
int zmq::req_t::xsetsockopt(int option_, const void *optval_, size_t optvallen_) int zmq::req_t::xsetsockopt (int option_, const void *optval_, size_t optvallen_)
{ {
bool is_int = (optvallen_ == sizeof (int)); bool is_int = (optvallen_ == sizeof (int));
int value = is_int? *((int *) optval_): 0; int value = is_int? *((int *) optval_): 0;
...@@ -216,17 +216,24 @@ int zmq::req_t::xsetsockopt(int option_, const void *optval_, size_t optvallen_) ...@@ -216,17 +216,24 @@ int zmq::req_t::xsetsockopt(int option_, const void *optval_, size_t optvallen_)
break; break;
} }
return dealer_t::xsetsockopt(option_, optval_, optvallen_); return dealer_t::xsetsockopt (option_, optval_, optvallen_);
}
void zmq::req_t::xpipe_terminated (pipe_t *pipe_)
{
if (reply_pipe == pipe_)
reply_pipe = NULL;
dealer_t::xpipe_terminated (pipe_);
} }
int zmq::req_t::recv_reply_pipe (msg_t *msg_) int zmq::req_t::recv_reply_pipe (msg_t *msg_)
{ {
while (true) { while (true) {
pipe_t *pipe = NULL; pipe_t *pipe = NULL;
int rc = dealer_t::recvpipe(msg_, &pipe); int rc = dealer_t::recvpipe (msg_, &pipe);
if (rc != 0) if (rc != 0)
return rc; return rc;
if (pipe == reply_pipe) if (!reply_pipe || pipe == reply_pipe)
return 0; return 0;
} }
} }
......
...@@ -44,6 +44,7 @@ namespace zmq ...@@ -44,6 +44,7 @@ namespace zmq
bool xhas_in (); bool xhas_in ();
bool xhas_out (); bool xhas_out ();
int xsetsockopt (int option_, const void *optval_, size_t optvallen_); int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
void xpipe_terminated (zmq::pipe_t *pipe_);
protected: protected:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment