Fix freeing r/w buffers on errors in kv_db
parent
e58538fa47
commit
9dc4d5fd7b
|
@ -701,15 +701,13 @@ void kv_db_t::find_size(uint64_t min, uint64_t max, int phase, std::function<voi
|
||||||
op->inode = inode_id;
|
op->inode = inode_id;
|
||||||
op->offset = (phase == 1 ? min : (min+max)/2) * ino_block_size;
|
op->offset = (phase == 1 ? min : (min+max)/2) * ino_block_size;
|
||||||
op->len = kv_block_size;
|
op->len = kv_block_size;
|
||||||
if (op->len)
|
op->iov.push_back(malloc_or_die(op->len), op->len);
|
||||||
{
|
|
||||||
op->iov.push_back(malloc_or_die(op->len), op->len);
|
|
||||||
}
|
|
||||||
op->callback = [=](cluster_op_t *op)
|
op->callback = [=](cluster_op_t *op)
|
||||||
{
|
{
|
||||||
if (op->retval != op->len)
|
if (op->retval != op->len)
|
||||||
{
|
{
|
||||||
// error
|
// error
|
||||||
|
free(op->iov.buf[0].iov_base);
|
||||||
cb(op->retval >= 0 ? -EIO : op->retval, 0);
|
cb(op->retval >= 0 ? -EIO : op->retval, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -896,7 +894,9 @@ static void get_block(kv_db_t *db, uint64_t offset, int cur_level, int recheck_p
|
||||||
if (op->retval != op->len)
|
if (op->retval != op->len)
|
||||||
{
|
{
|
||||||
// error
|
// error
|
||||||
|
free(op->iov.buf[0].iov_base);
|
||||||
cb(op->retval >= 0 ? -EIO : op->retval, BLK_NOCHANGE);
|
cb(op->retval >= 0 ? -EIO : op->retval, BLK_NOCHANGE);
|
||||||
|
delete op;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
invalidate(db, op->offset, op->version);
|
invalidate(db, op->offset, op->version);
|
||||||
|
@ -909,6 +909,8 @@ static void get_block(kv_db_t *db, uint64_t offset, int cur_level, int recheck_p
|
||||||
if (blk->updating > 0 && recheck_policy == KV_RECHECK_WAIT)
|
if (blk->updating > 0 && recheck_policy == KV_RECHECK_WAIT)
|
||||||
{
|
{
|
||||||
// Wait until block update stops
|
// Wait until block update stops
|
||||||
|
free(op->iov.buf[0].iov_base);
|
||||||
|
delete op;
|
||||||
db->continue_update.emplace(blk->offset, [=, blk_offset = blk->offset]()
|
db->continue_update.emplace(blk->offset, [=, blk_offset = blk->offset]()
|
||||||
{
|
{
|
||||||
get_block(db, offset, cur_level, recheck_policy, cb);
|
get_block(db, offset, cur_level, recheck_policy, cb);
|
||||||
|
@ -1339,6 +1341,8 @@ static void write_new_block(kv_db_t *db, kv_block_t *blk, std::function<void(int
|
||||||
del_block_level(db, blk);
|
del_block_level(db, blk);
|
||||||
db->block_cache.erase(blk->offset);
|
db->block_cache.erase(blk->offset);
|
||||||
cb(op->retval >= 0 ? -EIO : op->retval, NULL);
|
cb(op->retval >= 0 ? -EIO : op->retval, NULL);
|
||||||
|
free(op->iov.buf[0].iov_base);
|
||||||
|
delete op;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
invalidate(db, op->offset, op->version);
|
invalidate(db, op->offset, op->version);
|
||||||
|
@ -1353,6 +1357,8 @@ static void write_new_block(kv_db_t *db, kv_block_t *blk, std::function<void(int
|
||||||
// Block is already occupied => place again
|
// Block is already occupied => place again
|
||||||
place_again(db, blk, cb);
|
place_again(db, blk, cb);
|
||||||
}
|
}
|
||||||
|
free(op->iov.buf[0].iov_base);
|
||||||
|
delete op;
|
||||||
};
|
};
|
||||||
db->cli->execute(op);
|
db->cli->execute(op);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue