]> git.ipfire.org Git - people/ms/strongswan.git/commitdiff
Fixed load_secrets to acquire/release lock in level 0 only
authorMarius Tomaschewski <mt@suse.de>
Wed, 2 Sep 2009 11:49:39 +0000 (13:49 +0200)
committerMartin Willi <martin@strongswan.org>
Thu, 3 Sep 2009 12:46:36 +0000 (14:46 +0200)
The write_lock call fails with EDEADLK and unlocks in the
next recursion level.

src/charon/plugins/stroke/stroke_cred.c

index f878180e9812e92cdf511538d6b53eb0d7fb2a33..e34613efd8e1e3cf82559835e0a0d65077186bc3 100644 (file)
@@ -793,9 +793,10 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
        fclose(fd);
        src = chunk;
 
-       this->lock->write_lock(this->lock);
        if (level == 0)
        {
+               this->lock->write_lock(this->lock);
+
                /* flush secrets on non-recursive invocation */
                while (this->shared->remove_last(this->shared,
                                                                                 (void**)&shared) == SUCCESS)
@@ -1106,7 +1107,10 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                }
        }
 error:
-       this->lock->unlock(this->lock);
+       if (level == 0)
+       {
+               this->lock->unlock(this->lock);
+       }
        chunk_clear(&chunk);
 }