Avoid a deadlock when installing a trap policy failed
authorTobias Brunner <tobias@strongswan.org>
Wed, 23 Jan 2013 14:51:47 +0000 (15:51 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 23 Jan 2013 14:51:47 +0000 (15:51 +0100)
src/libcharon/sa/trap_manager.c

index 69b23e1..6c0ae19 100644 (file)
@@ -170,8 +170,8 @@ METHOD(trap_manager_t, install, u_int32_t,
        if (status != SUCCESS)
        {
                DBG1(DBG_CFG, "installing trap failed");
-               child_sa->destroy(child_sa);
                reqid = 0;
+               /* hold off destroying the CHILD_SA until we released the lock */
        }
        else
        {
@@ -184,6 +184,10 @@ METHOD(trap_manager_t, install, u_int32_t,
        }
        this->lock->unlock(this->lock);
 
+       if (status != SUCCESS)
+       {
+               child_sa->destroy(child_sa);
+       }
        if (found)
        {
                destroy_entry(found);