[ovs-dev] [PATCH 1/4] id-pool: Allocate the lowest available ids.
Ilya Maximets
i.maximets at samsung.com
Tue Feb 21 14:49:25 UTC 2017
This simple change makes id-pool to always allocate the
lowest possible id from the pool. No any other code affected
because, actually, there is no users of 'id_pool_free_id' in
OVS.
This behaviour of id-pool will be used in the next patch.
Signed-off-by: Ilya Maximets <i.maximets at samsung.com>
---
lib/id-pool.c | 3 +++
lib/id-pool.h | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/id-pool.c b/lib/id-pool.c
index 62a6b33..8f005e0 100644
--- a/lib/id-pool.c
+++ b/lib/id-pool.c
@@ -148,6 +148,9 @@ id_pool_free_id(struct id_pool *pool, uint32_t id)
id_node = id_pool_find(pool, id);
if (id_node) {
hmap_remove(&pool->map, &id_node->node);
+ if (id < pool->next_free_id) {
+ pool->next_free_id = id;
+ }
free(id_node);
}
}
diff --git a/lib/id-pool.h b/lib/id-pool.h
index 93a49c3..8721f87 100644
--- a/lib/id-pool.h
+++ b/lib/id-pool.h
@@ -35,7 +35,7 @@ void id_pool_add(struct id_pool *, uint32_t id);
* ========
*
* Pool of unique 32bit ids.
- *
+ * Allocation always returns the lowest available id.
*
* Thread-safety
* =============
--
2.7.4
More information about the dev
mailing list