mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-10 07:56:09 +00:00
Fix issue #268
This patch fixes a bug in the message encoder which was responsible for computing incorrect message offset. The bug affected PGM receiver making it unable to decode inital messages.
This commit is contained in:
parent
5dc44a63d6
commit
3d93c1af5b
@ -51,7 +51,7 @@ bool zmq::encoder_t::size_ready ()
|
|||||||
{
|
{
|
||||||
// Write message body into the buffer.
|
// Write message body into the buffer.
|
||||||
next_step (in_progress.data (), in_progress.size (),
|
next_step (in_progress.data (), in_progress.size (),
|
||||||
&encoder_t::message_ready, false);
|
&encoder_t::message_ready, !(in_progress.flags () & msg_t::more));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,15 +90,13 @@ bool zmq::encoder_t::message_ready ()
|
|||||||
if (size < 255) {
|
if (size < 255) {
|
||||||
tmpbuf [0] = (unsigned char) size;
|
tmpbuf [0] = (unsigned char) size;
|
||||||
tmpbuf [1] = (in_progress.flags () & msg_t::more);
|
tmpbuf [1] = (in_progress.flags () & msg_t::more);
|
||||||
next_step (tmpbuf, 2, &encoder_t::size_ready,
|
next_step (tmpbuf, 2, &encoder_t::size_ready, false);
|
||||||
!(in_progress.flags () & msg_t::more));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tmpbuf [0] = 0xff;
|
tmpbuf [0] = 0xff;
|
||||||
put_uint64 (tmpbuf + 1, size);
|
put_uint64 (tmpbuf + 1, size);
|
||||||
tmpbuf [9] = (in_progress.flags () & msg_t::more);
|
tmpbuf [9] = (in_progress.flags () & msg_t::more);
|
||||||
next_step (tmpbuf, 10, &encoder_t::size_ready,
|
next_step (tmpbuf, 10, &encoder_t::size_ready, false);
|
||||||
!(in_progress.flags () & msg_t::more));
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -79,19 +79,17 @@ namespace zmq
|
|||||||
// If there are still no data, return what we already have
|
// If there are still no data, return what we already have
|
||||||
// in the buffer.
|
// in the buffer.
|
||||||
if (!to_write) {
|
if (!to_write) {
|
||||||
|
// If we are to encode the beginning of a new message,
|
||||||
|
// adjust the message offset.
|
||||||
|
if (beginning)
|
||||||
|
if (offset_ && *offset_ == -1)
|
||||||
|
*offset_ = static_cast <int> (pos);
|
||||||
|
|
||||||
if (!(static_cast <T*> (this)->*next) ()) {
|
if (!(static_cast <T*> (this)->*next) ()) {
|
||||||
*data_ = buffer;
|
*data_ = buffer;
|
||||||
*size_ = pos;
|
*size_ = pos;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If beginning of the message was processed, adjust the
|
|
||||||
// first-message-offset.
|
|
||||||
if (beginning) {
|
|
||||||
if (offset_ && *offset_ == -1)
|
|
||||||
*offset_ = (int) pos;
|
|
||||||
beginning = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are no data in the buffer yet and we are able to
|
// If there are no data in the buffer yet and we are able to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user