From 908a402a75f5922ac708d57168954790510758c0 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 21 Aug 2024 03:47:40 +0200 Subject: [PATCH] Drop some shared pointer references after RCU writes When removing instances from some RCU managed list or vector, they can still live on as shared_ptr references on the RCU's dead wood stack. In many cases this is not an issue, in these cases it's prudent. see also 44610c7877fc25fe --- libs/ardour/monitor_port.cc | 5 +++++ libs/ardour/port_manager.cc | 3 +++ libs/ardour/session_bundles.cc | 1 + 3 files changed, 9 insertions(+) diff --git a/libs/ardour/monitor_port.cc b/libs/ardour/monitor_port.cc index 45db2addb1..6dd6588155 100644 --- a/libs/ardour/monitor_port.cc +++ b/libs/ardour/monitor_port.cc @@ -338,6 +338,11 @@ MonitorPort::clear_ports (bool instantly) MonitorInputChanged (i->first, false); /* EMIT SIGNAL */ } + if (instantly) { + /* release shared_ptr references */ + _monitor_ports.flush (); + } + if (!s) { return; } diff --git a/libs/ardour/port_manager.cc b/libs/ardour/port_manager.cc index 7da3445f8f..db611aec91 100644 --- a/libs/ardour/port_manager.cc +++ b/libs/ardour/port_manager.cc @@ -1158,6 +1158,9 @@ PortManager::update_input_ports (bool clear) * do this when called from ::reestablish_ports() * "JACK: Cannot connect ports owned by inactive clients" */ + /* .. but take the opportunity to clear out dead wood */ + _audio_input_ports.flush (); + _midi_input_ports.flush (); return; } diff --git a/libs/ardour/session_bundles.cc b/libs/ardour/session_bundles.cc index e0bd838460..558c63716c 100644 --- a/libs/ardour/session_bundles.cc +++ b/libs/ardour/session_bundles.cc @@ -75,6 +75,7 @@ Session::remove_bundle (std::shared_ptr bundle) if (removed) { BundleAddedOrRemoved (); /* EMIT SIGNAL */ + _bundles.flush (); } set_dirty();