*/
void pool_flush(struct pool_head *pool)
{
- void *temp;
+ void *temp, **next;
if (!pool)
return;
- while (1) {
- HA_SPIN_LOCK(POOL_LOCK, &pool->lock);
- temp = pool->free_list;
- if (!temp) {
- HA_SPIN_UNLOCK(POOL_LOCK, &pool->lock);
- break;
- }
- pool->free_list = *POOL_LINK(pool, temp);
+ HA_SPIN_LOCK(POOL_LOCK, &pool->lock);
+ next = pool->free_list;
+ while (next) {
+ temp = next;
+ next = *POOL_LINK(pool, temp);
pool->allocated--;
- HA_SPIN_UNLOCK(POOL_LOCK, &pool->lock);
+ }
+
+ next = pool->free_list;
+ pool->free_list = NULL;
+ HA_SPIN_UNLOCK(POOL_LOCK, &pool->lock);
+
+ while (next) {
+ temp = next;
+ next = *POOL_LINK(pool, temp);
pool_free_area(temp, pool->size + POOL_EXTRA);
}
/* here, we should have pool->allocated == pool->used */