From: Martin Willi Date: Thu, 20 Sep 2012 09:04:55 +0000 (+0200) Subject: In mem_pool, check for an existing ID entry before creating a new one X-Git-Tag: 5.0.1~81 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f0a2fef8a59979dc5c3b68e1e2c621c3c86df213;p=thirdparty%2Fstrongswan.git In mem_pool, check for an existing ID entry before creating a new one --- diff --git a/src/libhydra/attributes/mem_pool.c b/src/libhydra/attributes/mem_pool.c index ac85ab5363..1e150c794f 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);