diff --git a/src/libstrongswan/credentials/credential_factory.c b/src/libstrongswan/credentials/credential_factory.c index 1fa34192d..07e1de76e 100644 --- a/src/libstrongswan/credentials/credential_factory.c +++ b/src/libstrongswan/credentials/credential_factory.c @@ -140,6 +140,8 @@ METHOD(credential_factory_t, create, void*, this->recursive->set(this->recursive, (void*)level + 1); this->lock->read_lock(this->lock); + /* push this in case of a timeout during unit tests */ + thread_cleanup_push((thread_cleanup_t)this->lock->unlock, this->lock); enumerator = this->constructors->create_enumerator(this->constructors); while (enumerator->enumerate(enumerator, &entry)) { @@ -159,7 +161,7 @@ METHOD(credential_factory_t, create, void*, } } enumerator->destroy(enumerator); - this->lock->unlock(this->lock); + thread_cleanup_pop(TRUE); if (!construct && !level) {