diff options
author | Gan Qixin <ganqixin@huawei.com> | 2020-12-03 15:50:53 +0800 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2020-12-11 17:52:39 +0100 |
commit | f5056b70e631ad1c2b058223f9cc68a3ea510163 (patch) | |
tree | e609399544601358549e42c3ee7e71236a9f8d4d /block/curl.c | |
parent | c37c97366097a5ce1919d6fe12535e5f889b0317 (diff) |
block/curl: Use lock guard macros
Replace manual lock()/unlock() calls with lock guard macros
(QEMU_LOCK_GUARD/WITH_QEMU_LOCK_GUARD) in block/curl.
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201203075055.127773-3-ganqixin@huawei.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/curl.c')
-rw-r--r-- | block/curl.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/block/curl.c b/block/curl.c index 4f907c47be..d24a4c5897 100644 --- a/block/curl.c +++ b/block/curl.c @@ -564,23 +564,23 @@ static void curl_detach_aio_context(BlockDriverState *bs) BDRVCURLState *s = bs->opaque; int i; - qemu_mutex_lock(&s->mutex); - for (i = 0; i < CURL_NUM_STATES; i++) { - if (s->states[i].in_use) { - curl_clean_state(&s->states[i]); + WITH_QEMU_LOCK_GUARD(&s->mutex) { + for (i = 0; i < CURL_NUM_STATES; i++) { + if (s->states[i].in_use) { + curl_clean_state(&s->states[i]); + } + if (s->states[i].curl) { + curl_easy_cleanup(s->states[i].curl); + s->states[i].curl = NULL; + } + g_free(s->states[i].orig_buf); + s->states[i].orig_buf = NULL; } - if (s->states[i].curl) { - curl_easy_cleanup(s->states[i].curl); - s->states[i].curl = NULL; + if (s->multi) { + curl_multi_cleanup(s->multi); + s->multi = NULL; } - g_free(s->states[i].orig_buf); - s->states[i].orig_buf = NULL; - } - if (s->multi) { - curl_multi_cleanup(s->multi); - s->multi = NULL; } - qemu_mutex_unlock(&s->mutex); timer_del(&s->timer); } |