summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@samsung.com>2017-02-21 17:49:25 +0300
committerBen Pfaff <blp@ovn.org>2017-03-08 16:52:06 -0800
commitf596e8edd362015389a3532760aa9d41d8c2fd19 (patch)
tree5c63b5eea62d6e6488685ff4b6b362281a83668d /lib
parenta2673b6cea465b080a6198a0104e81e765dbf3dc (diff)
downloadopenvswitch-f596e8edd362015389a3532760aa9d41d8c2fd19.tar.gz
id-pool: Allocate the lowest available ids.
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@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/id-pool.c3
-rw-r--r--lib/id-pool.h2
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/id-pool.c b/lib/id-pool.c
index 62a6b3311..8f005e020 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 93a49c383..8721f8793 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
* =============