Fixed ZMQ_REQ_CORRELATE (see pull request #1730)

Problem: Since pull request #1730 was merged, protocol for REQ socket is
checked at the session level and this check does not take into account
the possibility of a request_id being part of the message. Thus the option
ZMQ_REQ_CORRELATE would no longer work.
This is now fixed: the possiblity of a 4 bytes integer being present
before the delimiter frame is taken into account (whether or not this
breaks the REQ/REP RFC is another issue).
This commit is contained in:
Frederic Tregon
2016-04-02 18:30:35 +02:00
parent 0feec7a72e
commit 625b618776
5 changed files with 27 additions and 71 deletions

View File

@@ -279,6 +279,21 @@ int zmq::req_session_t::push_msg (msg_t *msg_)
{
switch (state) {
case bottom:
if (msg_->flags () == msg_t::more) {
// In case option ZMQ_CORRELATE is on, allow request_id to be
// transfered as first frame (would be too cumbersome to check
// whether the option is actually on or not).
if (msg_->size () == sizeof (uint32_t)) {
state = request_id;
return session_base_t::push_msg (msg_);
}
else if (msg_->size () == 0) {
state = body;
return session_base_t::push_msg (msg_);
}
}
break;
case request_id:
if (msg_->flags () == msg_t::more && msg_->size () == 0) {
state = body;
return session_base_t::push_msg (msg_);