diff options
author | Martin Willi <martin@revosec.ch> | 2012-09-11 10:41:11 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2012-09-11 16:18:28 +0200 |
commit | 594c58e1118e496eadd284647755b16b74665337 (patch) | |
tree | 743e0f33a01beffab57e363fe1e154944c63dd01 /src/libcharon/plugins/stroke/stroke_attribute.c | |
parent | dc7b79d8a5c8104001bba4c52a8b3716a0cf6d88 (diff) | |
download | strongswan-594c58e1118e496eadd284647755b16b74665337.tar.bz2 strongswan-594c58e1118e496eadd284647755b16b74665337.tar.xz |
Pass the full list of pools to acquire_address, enumerate in providers
If the provider has access to the full pool list, it can enumerate
them twice, for example to search for existing leases first, and
only search for new leases in a second step.
Fixes lease enumeration in attr-sql using multiple pools.
Diffstat (limited to 'src/libcharon/plugins/stroke/stroke_attribute.c')
-rw-r--r-- | src/libcharon/plugins/stroke/stroke_attribute.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/libcharon/plugins/stroke/stroke_attribute.c b/src/libcharon/plugins/stroke/stroke_attribute.c index fa58a24e3..99392bfd7 100644 --- a/src/libcharon/plugins/stroke/stroke_attribute.c +++ b/src/libcharon/plugins/stroke/stroke_attribute.c @@ -90,19 +90,31 @@ static mem_pool_t *find_pool(private_stroke_attribute_t *this, char *name) } METHOD(attribute_provider_t, acquire_address, host_t*, - private_stroke_attribute_t *this, char *name, identification_t *id, + private_stroke_attribute_t *this, linked_list_t *pools, identification_t *id, host_t *requested) { + enumerator_t *enumerator; mem_pool_t *pool; host_t *addr = NULL; + char *name; + enumerator = pools->create_enumerator(pools); this->lock->read_lock(this->lock); - pool = find_pool(this, name); - if (pool) + while (enumerator->enumerate(enumerator, &name)) { - addr = pool->acquire_address(pool, id, requested); + pool = find_pool(this, name); + if (pool) + { + addr = pool->acquire_address(pool, id, requested); + if (addr) + { + break; + } + } } this->lock->unlock(this->lock); + enumerator->destroy(enumerator); + return addr; } |