From c7b9ba3ccdd5a18afb22dda1afee16c938076c25 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Fri, 17 Sep 2010 12:58:20 +0200 Subject: reconnection process fixed when failure occurs during init phase --- src/command.hpp | 3 ++- src/session.cpp | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/command.hpp b/src/command.hpp index a72d3ca..c64ca92 100644 --- a/src/command.hpp +++ b/src/command.hpp @@ -64,7 +64,8 @@ namespace zmq class own_t *object; } own; - // Attach the engine to the session. + // Attach the engine to the session. If engine is NULL, it informs + // session that the connection have failed. struct { struct i_engine *engine; unsigned char peer_identity_size; diff --git a/src/session.cpp b/src/session.cpp index fd6a7ee..eb23eee 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -178,6 +178,14 @@ void zmq::session_t::finalise () void zmq::session_t::process_attach (i_engine *engine_, const blob_t &peer_identity_) { + // If some other object (e.g. init) notifies us that the connection failed + // we need to start the reconnection process. + if (!engine_) { + zmq_assert (!engine); + detached (); + return; + } + // Check whether the required pipes already exist. If not so, we'll // create them and bind them to the socket object. reader_t *socket_reader = NULL; -- cgit v1.2.3