From b390d8c8a67c0b48a7e31f47c90b4d23f7fa5fc4 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 30 Dec 2015 04:11:14 -0500 Subject: possible extra housekeeping for control protocol modules. Currently this code isn't reached because we never call ControlProtocolManager::teardown() on inactive protocols. But at some point it might be appropriate to unload modules (.so/.dll/.dylib) even if the protocol was never instantiated --- libs/ardour/control_protocol_manager.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index 3856743e70..c042e4f0c0 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -193,6 +193,18 @@ int ControlProtocolManager::teardown (ControlProtocolInfo& cpi) { if (!cpi.protocol) { + + /* we could still have a descriptor even if the protocol was + never instantiated. Close the associated module (shared + object/DLL) and make sure we forget about it. + */ + + if (cpi.descriptor) { + cerr << "Closing descriptor for CPI anyway\n"; + delete (Glib::Module*) cpi.descriptor->module; + cpi.descriptor = 0; + } + return 0; } @@ -226,7 +238,7 @@ ControlProtocolManager::teardown (ControlProtocolInfo& cpi) delete cpi.state; cpi.state = 0; - + cerr << "Tear down CPI module for " << cpi.name << endl; delete (Glib::Module*) cpi.descriptor->module; /* cpi->descriptor is now inaccessible since dlclose() or equivalent * has been performed, and the descriptor is (or could be) a static -- cgit v1.2.3