trap-manager: Wait for install to finish before uninstalling

There was a race condition between install() and uninstall()
where one thread was in the process of installing a trap
entry, and had destroyed the child_sa, while the other
thread was uninstalling the same trap entry and ended up
trying to destroy the already destroyed child_sa, resulting
in a segmentation fault in the destroy_entry() function.

The uninstall() function needs to wait until all the threads
are done with the installing before proceeding to uninstall
a trap entry.

Closes strongswan/strongswan#131.
This commit is contained in:
Sheena Mira-ato 2019-03-21 12:30:56 +13:00 committed by Tobias Brunner
parent 6ec9f68f32
commit 69cbe2ca3f
1 changed files with 4 additions and 0 deletions

View File

@ -352,6 +352,10 @@ METHOD(trap_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->traps->create_enumerator(this->traps);
while (enumerator->enumerate(enumerator, &entry))
{