diff mbox

[ovs-dev,1/4] id-pool: Allocate the lowest available ids.

Message ID 1487688568-14820-2-git-send-email-i.maximets@samsung.com
State Accepted
Headers show

Commit Message

Ilya Maximets Feb. 21, 2017, 2:49 p.m. UTC
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>
---
 lib/id-pool.c | 3 +++
 lib/id-pool.h | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Ben Pfaff March 9, 2017, 12:53 a.m. UTC | #1
On Tue, Feb 21, 2017 at 05:49:25PM +0300, Ilya Maximets wrote:
> 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>

Thanks, applied to master.
diff mbox

Patch

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
  * =============