[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/34] block/curl: Use lock guard macros
From: |
Kevin Wolf |
Subject: |
[PULL 02/34] block/curl: Use lock guard macros |
Date: |
Fri, 11 Dec 2020 18:07:40 +0100 |
From: Gan Qixin <ganqixin@huawei.com>
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>
---
block/curl.c | 28 ++++++++++++++--------------
1 file 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);
}
--
2.29.2
- [PULL 00/34] Block layer patches, Kevin Wolf, 2020/12/11
- [PULL 02/34] block/curl: Use lock guard macros,
Kevin Wolf <=
- [PULL 01/34] block/accounting: Use lock guard macros, Kevin Wolf, 2020/12/11
- [PULL 04/34] block/iscsi: Use lock guard macros, Kevin Wolf, 2020/12/11
- [PULL 03/34] block/throttle-groups: Use lock guard macros, Kevin Wolf, 2020/12/11
- [PULL 06/34] fuse: Allow exporting BDSs via FUSE, Kevin Wolf, 2020/12/11
- [PULL 08/34] fuse: Allow growable exports, Kevin Wolf, 2020/12/11
- [PULL 07/34] fuse: Implement standard FUSE operations, Kevin Wolf, 2020/12/11
- [PULL 05/34] meson: Detect libfuse, Kevin Wolf, 2020/12/11
- [PULL 09/34] fuse: (Partially) implement fallocate(), Kevin Wolf, 2020/12/11
- [PULL 10/34] fuse: Implement hole detection through lseek, Kevin Wolf, 2020/12/11
- [PULL 12/34] iotests: Do not pipe _make_test_img, Kevin Wolf, 2020/12/11