From f0a2fef8a59979dc5c3b68e1e2c621c3c86df213 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Thu, 20 Sep 2012 11:04:55 +0200 Subject: [PATCH] In mem_pool, check for an existing ID entry before creating a new one --- src/libhydra/attributes/mem_pool.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/libhydra/attributes/mem_pool.c b/src/libhydra/attributes/mem_pool.c index ac85ab536..1e150c794 100644 --- a/src/libhydra/attributes/mem_pool.c +++ b/src/libhydra/attributes/mem_pool.c @@ -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);