Fixed load_secrets to acquire/release lock in level 0 only

The write_lock call fails with EDEADLK and unlocks in the
next recursion level.
This commit is contained in:
Marius Tomaschewski
2009-09-03 14:46:36 +02:00
committed by Martin Willi
parent 12a230ddb4
commit dece3d8efc
+6 -2
View File
@@ -793,9 +793,10 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
fclose(fd); fclose(fd);
src = chunk; src = chunk;
this->lock->write_lock(this->lock);
if (level == 0) if (level == 0)
{ {
this->lock->write_lock(this->lock);
/* flush secrets on non-recursive invocation */ /* flush secrets on non-recursive invocation */
while (this->shared->remove_last(this->shared, while (this->shared->remove_last(this->shared,
(void**)&shared) == SUCCESS) (void**)&shared) == SUCCESS)
@@ -1106,7 +1107,10 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
} }
} }
error: error:
this->lock->unlock(this->lock); if (level == 0)
{
this->lock->unlock(this->lock);
}
chunk_clear(&chunk); chunk_clear(&chunk);
} }