shunt-manager: Fix potential race between install and uninstall

If the installation fails while a shunt is concurrently uninstalled,
the entry could already be destroyed when trying to remove and destroy
it after acquiring the lock again in `install()`.

This change handles the conflict the same way trap-manager does since
69cbe2ca3f ("trap-manager: Wait for install to finish before
uninstalling").

Fixes: 616ff9a236 ("shunt-manager: Remove stored entries if installation fails")
This commit is contained in:
Tobias Brunner
2026-07-24 08:47:38 +02:00
parent 40f40973c0
commit 6dca323ae0
+4
View File
@@ -377,6 +377,10 @@ METHOD(shunt_manager_t, uninstall, bool,
entry_t *entry, *found = NULL;
this->lock->write_lock(this->lock);
while (this->installing)
{
this->condvar->wait(this->condvar, this->lock);
}
enumerator = this->shunts->create_enumerator(this->shunts);
while (enumerator->enumerate(enumerator, &entry))
{