From 964a372d677f6b405199377544e327b4e9ff496d Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 14 Oct 2014 04:10:54 +0200 Subject: [PATCH] Fix re-entrance in Application shutdown(#954) doh... this happens when you draft some quite intricate logic and then get sidelined with other tasks for several years. Mind me, I didn't even recall that I had treated this whole issue and created a clean-up thread. A full fledged implementation would have a real lifecycle and thus detect the re-entrance; but since none of the components to be managed by the OutputDirector is even remotely planned or even coded, the functions were just drafted as stubs. Which caused us happily to create yet another clean-up thread whenever the subsystem-runner signalled "please shut down". --- src/proc/play/output-director.cpp | 10 +++++++--- src/proc/play/output-director.hpp | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/proc/play/output-director.cpp b/src/proc/play/output-director.cpp index f9fd3ea30..416445700 100644 --- a/src/proc/play/output-director.cpp +++ b/src/proc/play/output-director.cpp @@ -60,19 +60,19 @@ namespace play { /** connect and bring up the external input/output connections, * handlers and interface services and the render/playback service. * @return true if the output subsystem can be considered operational - * - * @todo WIP-WIP-WIP 6/2011 */ bool OutputDirector::connectUp() { Lock sync(this); + REQUIRE (!shutdown_initiated_); player_.reset (new PlayService); return this->isOperational(); } + /** @todo WIP-WIP-WIP 6/2011 */ bool OutputDirector::isOperational() const { @@ -92,7 +92,11 @@ namespace play { void OutputDirector::triggerDisconnect (SigTerm completedSignal) throw() { - Thread ("Output shutdown supervisor", bind (&OutputDirector::bringDown, this, completedSignal)); + if (!shutdown_initiated_) + { + shutdown_initiated_ = true; + Thread ("Output shutdown supervisor", bind (&OutputDirector::bringDown, this, completedSignal)); + } } diff --git a/src/proc/play/output-director.hpp b/src/proc/play/output-director.hpp index 582b3d81c..90dc27245 100644 --- a/src/proc/play/output-director.hpp +++ b/src/proc/play/output-director.hpp @@ -76,6 +76,9 @@ namespace play { typedef lumiera::Subsys::SigTerm SigTerm; scoped_ptr player_; + ///////TODO more components and connections to manage here... + + bool shutdown_initiated_ = false; /////TODO probably need a way more elaborate lifecylce management public: static lib::Depend instance;