summaryrefslogtreecommitdiff
path: root/src/own.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2010-10-16 10:53:29 +0200
committerMartin Sustrik <sustrik@250bpm.com>2010-10-16 10:53:29 +0200
commit0a03e86e9547fa7c221b316a5a943467adea3dfd (patch)
treef47b0cd7d3c91c59de419506f8d66c27e327e41c /src/own.cpp
parenta1474e305762d32df2b79300d124aac7fa0181c8 (diff)
ZMQ_LINGER socket option added.
1. ZMQ_LINGER option can be set/get 2. options are part of own_t base class rather than being declared separately by individual objects 3. Linger option is propagated with "term" command so that the newest value of it is used rather than the stored old one. 4. Session sets the linger timer if needed and terminates as soon as it expires. 5. Corresponding documentation updated. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/own.cpp')
-rw-r--r--src/own.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/own.cpp b/src/own.cpp
index 12f50bf..c91650d 100644
--- a/src/own.cpp
+++ b/src/own.cpp
@@ -31,8 +31,9 @@ zmq::own_t::own_t (class ctx_t *parent_, uint32_t slot_) :
{
}
-zmq::own_t::own_t (io_thread_t *io_thread_) :
+zmq::own_t::own_t (io_thread_t *io_thread_, const options_t &options_) :
object_t (io_thread_),
+ options (options_),
terminating (false),
sent_seqnum (0),
processed_seqnum (0),
@@ -113,16 +114,19 @@ void zmq::own_t::process_term_req (own_t *object_)
owned.erase (it);
register_term_acks (1);
- send_term (object_);
+
+ // Note that this object is the root of the (partial shutdown) thus, its
+ // value of linger is used, rather than the value stored by the children.
+ send_term (object_, options.linger);
}
void zmq::own_t::process_own (own_t *object_)
{
// If the object is already being shut down, new owned objects are
- // immediately asked to terminate.
+ // immediately asked to terminate. Note that linger is set to zero.
if (terminating) {
register_term_acks (1);
- send_term (object_);
+ send_term (object_, 0);
return;
}
@@ -140,7 +144,7 @@ void zmq::own_t::terminate ()
// As for the root of the ownership tree, there's noone to terminate it,
// so it has to terminate itself.
if (!owner) {
- process_term ();
+ process_term (options.linger);
return;
}
@@ -148,14 +152,14 @@ void zmq::own_t::terminate ()
send_term_req (owner, this);
}
-void zmq::own_t::process_term ()
+void zmq::own_t::process_term (int linger_)
{
// Double termination should never happen.
zmq_assert (!terminating);
- // Send termination request to all owned objects.
+ // Send termination request to all owned objects.
for (owned_t::iterator it = owned.begin (); it != owned.end (); it++)
- send_term (*it);
+ send_term (*it, linger_);
register_term_acks (owned.size ());
owned.clear ();