Fixed deadlock if checkin_and_destroy is called during shutdown.
authorTobias Brunner <tobias@strongswan.org>
Thu, 1 Mar 2012 11:52:17 +0000 (12:52 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 20 Mar 2012 16:31:40 +0000 (17:31 +0100)
src/libcharon/sa/ike_sa_manager.c

index 74a33dd..e981744 100644 (file)
@@ -1490,6 +1490,16 @@ METHOD(ike_sa_manager_t, checkin_and_destroy, void,
 
        if (get_entry_by_sa(this, ike_sa_id, ike_sa, &entry, &segment) == SUCCESS)
        {
+               if (entry->driveout_waiting_threads && entry->driveout_new_threads)
+               {       /* it looks like flush() has been called and the SA is being deleted
+                        * anyway, just check it in */
+                       DBG2(DBG_MGR, "ignored check-in and destroy of IKE_SA during shutdown");
+                       entry->checked_out = FALSE;
+                       entry->condvar->broadcast(entry->condvar);
+                       unlock_single_segment(this, segment);
+                       return;
+               }
+
                /* drive out waiting threads, as we are in hurry */
                entry->driveout_waiting_threads = TRUE;
                /* mark it, so no new threads can get this entry */