Fixed issue with req assertions (issue 252)

Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
Mikko Koppanen
2011-09-13 16:27:07 +02:00
committed by Martin Sustrik
parent e191e806ea
commit 8f8bfcaba0
3 changed files with 95 additions and 3 deletions

View File

@@ -89,8 +89,13 @@ int zmq::req_t::xrecv (msg_t *msg_, int flags_)
int rc = xreq_t::xrecv (msg_, flags_);
if (rc != 0)
return rc;
zmq_assert (msg_->flags () & msg_t::label);
zmq_assert (msg_->size () == 4);
// TODO: This should also close the connection with the peer!
if (unlikely (!(msg_->flags () & msg_t::label) || msg_->size () != 4)) {
errno = EAGAIN;
return -1;
}
unsigned char *data = (unsigned char*) msg_->data ();
if (unlikely (get_uint32 (data) != request_id)) {