diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2011-09-16 09:29:43 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2011-09-16 09:29:43 +0200 |
commit | 06bdf2c4f96a6324b3fe667cebb03d44cd100a73 (patch) | |
tree | e7678e0f861ae538fe03c75484d708042f62659d /src/session_base.cpp | |
parent | f78d9b6bfca13e298c29fadabbbc870b37a0a573 (diff) |
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>
Diffstat (limited to 'src/session_base.cpp')
-rw-r--r-- | src/session_base.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/session_base.cpp b/src/session_base.cpp index 7d4c5ab..32dcd4f 100644 --- a/src/session_base.cpp +++ b/src/session_base.cpp @@ -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 () |