[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-stable] [Qemu-block] [PATCH 4/7] curl: split curl_find_state/c
From: |
Max Reitz |
Subject: |
Re: [Qemu-stable] [Qemu-block] [PATCH 4/7] curl: split curl_find_state/curl_init_state |
Date: |
Wed, 10 May 2017 19:26:57 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 |
On 10.05.2017 16:32, Paolo Bonzini wrote:
> If curl_easy_init fails, a CURLState is left with s->in_use = 1. Split
> curl_init_state in two, so that we can distinguish the two failures and
> call curl_clean_state if needed.
>
> While at it, simplify curl_find_state, removing a dummy loop. The
> aio_poll loop is moved to the sole caller that needs it.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
> block/curl.c | 52 ++++++++++++++++++++++++++++++----------------------
> 1 file changed, 30 insertions(+), 22 deletions(-)
>
> diff --git a/block/curl.c b/block/curl.c
> index b18e79bf54..4b4d5a2389 100644
> --- a/block/curl.c
> +++ b/block/curl.c
[...]
> @@ -856,8 +854,18 @@ static void curl_readv_bh_cb(void *p)
> }
>
> // No cache found, so let's start a new request
> - state = curl_init_state(acb->common.bs, s);
> - if (!state) {
> + for (;;) {
> + state = curl_find_state(s);
> + if (state) {
> + break;
> + }
> + qemu_mutex_unlock(&s->mutex);
> + aio_poll(bdrv_get_aio_context(bs), true);
> + qemu_mutex_lock(&s->mutex);
> + }
> +
> + if (curl_init_state(s, state) < 0) {
> + curl_clean_state(state);
We could also initialize state to NULL and call curl_clean_state() under
out: if state != NULL. Then again, it would only save us two
curl_clean_state() instances...
So I'll leave it to you and unconditionally give a
Reviewed-by: Max Reitz <address@hidden>
> ret = -EIO;
> goto out;
> }
>
signature.asc
Description: OpenPGP digital signature
- [Qemu-stable] [PATCH v2 0/7] curl: locking cleanups/fixes, coroutine conversion, remove aio_poll, Paolo Bonzini, 2017/05/10
- [Qemu-stable] [PATCH 1/7] curl: strengthen assertion in curl_clean_state, Paolo Bonzini, 2017/05/10
- [Qemu-stable] [PATCH 2/7] curl: never invoke callbacks with s->mutex held, Paolo Bonzini, 2017/05/10
- [Qemu-stable] [PATCH 4/7] curl: split curl_find_state/curl_init_state, Paolo Bonzini, 2017/05/10
- [Qemu-stable] [PATCH 3/7] curl: avoid recursive locking of BDRVCURLState mutex, Paolo Bonzini, 2017/05/10
- [Qemu-stable] [PATCH 7/7] curl: do not do aio_poll when waiting for a free CURLState, Paolo Bonzini, 2017/05/10
- [Qemu-stable] [PATCH 5/7] curl: convert CURLAIOCB to byte values, Paolo Bonzini, 2017/05/10