From d1373792f7888f312cd7286fdf524a0bfe124846 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 23 Jun 2011 07:57:47 +0200 Subject: Outstanding requests dropped when requester dies (issue 190) So far the requests in req/rep pattern were delivered to and processed by worker even though the original requester was dead. Thus, the worker processing replies with noone to deliver results to. This optimisation drops requests in two situations: 1. Queued inbound requests in XREP socket when peer disconnects. 2. Queued outbound requests in XREQ when socket is closed. Signed-off-by: Martin Sustrik --- src/xrep.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/xrep.cpp') diff --git a/src/xrep.cpp b/src/xrep.cpp index 4a474cf..fe9ab52 100644 --- a/src/xrep.cpp +++ b/src/xrep.cpp @@ -33,6 +33,10 @@ zmq::xrep_t::xrep_t (class ctx_t *parent_, uint32_t tid_) : { options.type = ZMQ_XREP; + // If peer disconnect there's noone to send reply to anyway. We can drop + // all the outstanding requests from that peer. + options.delay_on_disconnect = false; + prefetched_msg.init (); // Start the peer ID sequence from a random point. -- cgit v1.2.3