Remove entry from active duplicate list only if it was not in checking
authorMartin Willi <martin@revosec.ch>
Tue, 22 Feb 2011 10:16:13 +0000 (11:16 +0100)
committerMartin Willi <martin@revosec.ch>
Mon, 28 Feb 2011 15:37:18 +0000 (15:37 +0000)
src/libcharon/plugins/duplicheck/duplicheck_listener.c

index 0902a67..1942084 100644 (file)
@@ -137,11 +137,6 @@ METHOD(listener_t, ike_updown, bool,
        else
        {
                this->mutex->lock(this->mutex);
-               entry = this->active->remove(this->active, id);
-               if (entry)
-               {
-                       entry_destroy(entry);
-               }
                entry = this->checking->remove(this->checking, id);
                this->mutex->unlock(this->mutex);
                if (entry)
@@ -150,6 +145,16 @@ METHOD(listener_t, ike_updown, bool,
                                 "keeping new IKE_SA", id);
                        entry_destroy(entry);
                }
+               else
+               {
+                       this->mutex->lock(this->mutex);
+                       entry = this->active->remove(this->active, id);
+                       this->mutex->unlock(this->mutex);
+                       if (entry)
+                       {
+                               entry_destroy(entry);
+                       }
+               }
        }
        return TRUE;
 }