summaryrefslogtreecommitdiff
path: root/src/zmq_engine.cpp
diff options
context:
space:
mode:
authorDhammika Pathirana <dhammika@gmail.com>2010-10-23 20:59:54 +0200
committerMartin Sustrik <sustrik@250bpm.com>2010-10-23 20:59:54 +0200
commit71bef330fc9f09ee070c90d174fc0bcb7783b38d (patch)
tree831702e8b6a3f8ee18f0a738747fe88b4d44bb96 /src/zmq_engine.cpp
parent8d6979922efff7183ce03b49715472e5b2a6a1df (diff)
handle decoding malformed messages
Signed-off-by: Dhammika Pathirana <dhammika@gmail.com>
Diffstat (limited to 'src/zmq_engine.cpp')
-rw-r--r--src/zmq_engine.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/zmq_engine.cpp b/src/zmq_engine.cpp
index 815697c..761f6fe 100644
--- a/src/zmq_engine.cpp
+++ b/src/zmq_engine.cpp
@@ -119,18 +119,24 @@ void zmq::zmq_engine_t::in_event ()
// Push the data to the decoder.
size_t processed = decoder.process_buffer (inpos, insize);
- // Stop polling for input if we got stuck.
- if (processed < insize) {
-
- // This may happen if queue limits are in effect or when
- // init object reads all required information from the socket
- // and rejects to read more data.
- reset_pollin (handle);
+ if (unlikely (processed == (size_t) -1)) {
+ disconnection = true;
}
+ else {
+
+ // Stop polling for input if we got stuck.
+ if (processed < insize) {
- // Adjust the buffer.
- inpos += processed;
- insize -= processed;
+ // This may happen if queue limits are in effect or when
+ // init object reads all required information from the socket
+ // and rejects to read more data.
+ reset_pollin (handle);
+ }
+
+ // Adjust the buffer.
+ inpos += processed;
+ insize -= processed;
+ }
// Flush all messages the decoder may have produced.
inout->flush ();