]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
In mem_pool, check for an existing ID entry before creating a new one
authorMartin Willi <martin@revosec.ch>
Thu, 20 Sep 2012 09:04:55 +0000 (11:04 +0200)
committerMartin Willi <martin@revosec.ch>
Thu, 20 Sep 2012 09:04:55 +0000 (11:04 +0200)
src/libhydra/attributes/mem_pool.c

index ac85ab536309e0d54543dbe495a0d659bb364941..1e150c794f2efb536ca4ac16c06ab52de18e40e2 100644 (file)
@@ -272,13 +272,16 @@ static int get_new(private_mem_pool_t *this, identification_t *id)
 
        if (this->unused < this->size)
        {
-               INIT(entry,
-                       .id = id->clone(id),
-                       .online = linked_list_create(),
-                       .offline = linked_list_create(),
-               );
-               this->leases->put(this->leases, entry->id, entry);
-
+               entry = this->leases->get(this->leases, id);
+               if (!entry)
+               {
+                       INIT(entry,
+                               .id = id->clone(id),
+                               .online = linked_list_create(),
+                               .offline = linked_list_create(),
+                       );
+                       this->leases->put(this->leases, entry->id, entry);
+               }
                /* assigning offset, starting by 1 */
                offset = ++this->unused;
                entry->online->insert_last(entry->online, (void*)offset);