From 67497a26439239fdb95652b46d7e4e41fe672b31 Mon Sep 17 00:00:00 2001 From: Ian Barber Date: Fri, 8 Jun 2012 23:55:42 +0100 Subject: [PATCH] Use the hiccup mechanism to notify the socket end of the pair of the change in state, and have it shutdown that end, and shutdown the local end normally. This seems to resolve the shutdown and race condition issues. --- src/session_base.cpp | 6 +++--- src/socket_base.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/session_base.cpp b/src/session_base.cpp index 50686e09..172aaaa4 100644 --- a/src/session_base.cpp +++ b/src/session_base.cpp @@ -395,15 +395,15 @@ void zmq::session_base_t::detached () return; } - reset (); - // For delayed connect situations, terminate the pipe // and reestablish later on if (pipe && options.delay_attach_on_connect == 1 && addr->protocol != "pgm" && addr->protocol != "epgm") { + pipe->hiccup (); pipe->terminate (false); - pipe = NULL; } + + reset (); // Reconnect. if (options.reconnect_ivl != -1) diff --git a/src/socket_base.cpp b/src/socket_base.cpp index 50d1aa6e..7e1aa0c6 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -916,7 +916,7 @@ void zmq::socket_base_t::xwrite_activated (pipe_t *pipe_) void zmq::socket_base_t::xhiccuped (pipe_t *pipe_) { - zmq_assert (false); + zmq_assert ( options.delay_attach_on_connect == 1 ); } void zmq::socket_base_t::in_event () @@ -970,6 +970,11 @@ void zmq::socket_base_t::write_activated (pipe_t *pipe_) void zmq::socket_base_t::hiccuped (pipe_t *pipe_) { + if( options.delay_attach_on_connect == 1 ) { + pipe_->terminate (false); + } + + // Notify derived sockets of the hiccup xhiccuped (pipe_); }