aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block/curl.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/block/curl.c b/block/curl.c
index 4f907c4..d24a4c5 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);
}