From 41dc2e60493ff1f10a8d2c4c8ae41f55ee4c327e Mon Sep 17 00:00:00 2001 From: Martin Hurton Date: Fri, 2 Nov 2012 11:11:14 +0100 Subject: [PATCH] Resolve LIBZMQ-459 Ref: https://zeromq.jira.com/browse/LIBZMQ-459 --- src/stream_engine.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/stream_engine.cpp b/src/stream_engine.cpp index 94f8cd32..413b87ec 100644 --- a/src/stream_engine.cpp +++ b/src/stream_engine.cpp @@ -263,8 +263,15 @@ void zmq::stream_engine_t::out_event () // If write buffer is empty, try to read new data from the encoder. if (!outsize) { + // Even when we stop polling as soon as there is no + // data to send, the poller may invoke out_event one + // more time due to 'speculative write' optimisation. + if (unlikely (encoder == NULL)) { + zmq_assert (handshaking); + return; + } + outpos = NULL; - zmq_assert (encoder); encoder->get_data (&outpos, &outsize); // If there is no data to send, stop polling for output.