summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@fastmq.commkdir>2009-09-14 13:54:30 +0200
committerMartin Sustrik <sustrik@fastmq.commkdir>2009-09-14 13:54:30 +0200
commit2bc9419ced21151fe90c530758dc85b7024fdb70 (patch)
treef59dac8b51af4f33f9150eb104d843337c55a700 /src
parent37cacc5700eaaaddbe2df6e3affeca4a335b023a (diff)
ZMQII-10: Make connections interrupted during the init phase be closed silently
Diffstat (limited to 'src')
-rw-r--r--src/zmq_decoder.cpp13
-rw-r--r--src/zmq_listener_init.cpp7
2 files changed, 16 insertions, 4 deletions
diff --git a/src/zmq_decoder.cpp b/src/zmq_decoder.cpp
index e51d802..53811a1 100644
--- a/src/zmq_decoder.cpp
+++ b/src/zmq_decoder.cpp
@@ -20,6 +20,7 @@
#include "zmq_decoder.hpp"
#include "i_inout.hpp"
#include "wire.hpp"
+#include "err.hpp"
zmq::zmq_decoder_t::zmq_decoder_t () :
destination (NULL)
@@ -48,7 +49,11 @@ bool zmq::zmq_decoder_t::one_byte_size_ready ()
if (*tmpbuf == 0xff)
next_step (tmpbuf, 8, &zmq_decoder_t::eight_byte_size_ready);
else {
- zmq_msg_init_size (&in_progress, *tmpbuf);
+
+ // TODO: Handle over-sized message decently.
+ int rc = zmq_msg_init_size (&in_progress, *tmpbuf);
+ errno_assert (rc == 0);
+
next_step (zmq_msg_data (&in_progress), *tmpbuf,
&zmq_decoder_t::message_ready);
}
@@ -60,7 +65,11 @@ bool zmq::zmq_decoder_t::eight_byte_size_ready ()
// 8-byte size is read. Allocate the buffer for message body and
// read the message data into it.
size_t size = (size_t) get_uint64 (tmpbuf);
- zmq_msg_init_size (&in_progress, size);
+
+ // TODO: Handle over-sized message decently.
+ int rc = zmq_msg_init_size (&in_progress, size);
+ errno_assert (rc == 0);
+
next_step (zmq_msg_data (&in_progress), size,
&zmq_decoder_t::message_ready);
return true;
diff --git a/src/zmq_listener_init.cpp b/src/zmq_listener_init.cpp
index 98a3780..756e9d8 100644
--- a/src/zmq_listener_init.cpp
+++ b/src/zmq_listener_init.cpp
@@ -93,8 +93,11 @@ void zmq::zmq_listener_init_t::flush ()
void zmq::zmq_listener_init_t::detach ()
{
- // TODO: Engine is closing down. Init object is to be closed as well.
- zmq_assert (false);
+ // This function is called by engine when disconnection occurs.
+ // The engine will destroy itself, so we just drop the pointer here and
+ // start termination of the init object.
+ engine = NULL;
+ term ();
}
void zmq::zmq_listener_init_t::process_plug ()