Check message syntax in REQ asynchronously

This patch adds support for checking messages as they arrive
(as opposed to when they are recv'd by the user) and drop
the connection if they are malformed.

It also uses this new feature to check for validity of inbound
messages in REQ socket.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
Martin Sustrik
2011-09-16 09:29:43 +02:00
parent f78d9b6bfc
commit 06bdf2c4f9
8 changed files with 74 additions and 14 deletions

View File

@@ -148,28 +148,28 @@ void zmq::session_base_t::attach_pipe (pipe_t *pipe_)
pipe->set_event_sink (this);
}
bool zmq::session_base_t::read (msg_t *msg_)
int zmq::session_base_t::read (msg_t *msg_)
{
if (!pipe)
return false;
if (!pipe->read (msg_))
return false;
if (!pipe || !pipe->read (msg_)) {
errno = EAGAIN;
return -1;
}
incomplete_in =
msg_->flags () & (msg_t::more | msg_t::label) ? true : false;
return true;
return 0;
}
bool zmq::session_base_t::write (msg_t *msg_)
int zmq::session_base_t::write (msg_t *msg_)
{
if (pipe && pipe->write (msg_)) {
int rc = msg_->init ();
errno_assert (rc == 0);
return true;
return 0;
}
return false;
errno = EAGAIN;
return -1;
}
void zmq::session_base_t::flush ()