Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
pool->fd = fd;
- global_write_lock();
nr_pools++;
- global_write_unlock();
return 0;
out_unlink:
fprintf(stderr, "smalloc: failed adding pool\n");
{
unsigned int i;
- global_read_lock();
+ global_write_lock();
i = last_pool;
do {
if (ptr) {
last_pool = i;
- global_read_unlock();
+ global_write_unlock();
return ptr;
}
}
break;
else {
i = nr_pools;
- global_read_unlock();
if (add_pool(&mp[nr_pools], size))
goto out;
- global_read_lock();
}
} while (1);
- global_read_unlock();
out:
+ global_write_unlock();
return NULL;
}