From 4172a00373b2c81374293becc02b16b7f8c76659 Mon Sep 17 00:00:00 2001 From: "sochin.jiang" Date: Thu, 15 Jun 2017 14:47:33 +0800 Subject: fix: avoid an infinite loop or a dangling pointer problem in img_commit img_commit could fall into an infinite loop calling run_block_job() if its blockjob fails on any I/O error, fix this already known problem. Signed-off-by: sochin.jiang Message-id: 1497509253-28941-1-git-send-email-sochin.jiang@huawei.com Signed-off-by: Max Reitz --- include/block/blockjob.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include/block') diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 09c7c694b5..67c0968fa5 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -320,6 +320,24 @@ void block_job_iostatus_reset(BlockJob *job); */ BlockJobTxn *block_job_txn_new(void); +/** + * block_job_ref: + * + * Add a reference to BlockJob refcnt, it will be decreased with + * block_job_unref, and then be freed if it comes to be the last + * reference. + */ +void block_job_ref(BlockJob *job); + +/** + * block_job_unref: + * + * Release a reference that was previously acquired with block_job_ref + * or block_job_create. If it's the last reference to the object, it will be + * freed. + */ +void block_job_unref(BlockJob *job); + /** * block_job_txn_unref: * -- cgit v1.2.3