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/decoder.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/decoder.cpp')
-rw-r--r-- | src/decoder.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/decoder.cpp b/src/decoder.cpp index 9e93b73..d57265a 100644 --- a/src/decoder.cpp +++ b/src/decoder.cpp @@ -23,6 +23,7 @@ #include "decoder.hpp" #include "session_base.hpp" +#include "likely.hpp" #include "wire.hpp" #include "err.hpp" @@ -136,8 +137,14 @@ bool zmq::decoder_t::message_ready () { // Message is completely read. Push it further and start reading // new message. (in_progress is a 0-byte message after this point.) - if (!session || !session->write (&in_progress)) + if (unlikely (!session)) return false; + int rc = session->write (&in_progress); + if (unlikely (rc != 0)) { + if (errno != EAGAIN) + decoding_error (); + return false; + } next_step (tmpbuf, 1, &decoder_t::one_byte_size_ready); return true; |