diff options
author | Martin Willi <martin@revosec.ch> | 2012-09-20 11:04:55 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2012-09-20 11:04:55 +0200 |
commit | f0a2fef8a59979dc5c3b68e1e2c621c3c86df213 (patch) | |
tree | 7a3d946f9fa72557242d12165eefaeb9003dfff2 /src | |
parent | a69bc12a3ac16835f28b333dcf0e5b43aab77f45 (diff) | |
download | strongswan-f0a2fef8a59979dc5c3b68e1e2c621c3c86df213.tar.bz2 strongswan-f0a2fef8a59979dc5c3b68e1e2c621c3c86df213.tar.xz |
In mem_pool, check for an existing ID entry before creating a new one
Diffstat (limited to 'src')
-rw-r--r-- | src/libhydra/attributes/mem_pool.c | 17 |
1 files 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); |