]> git.proxmox.com Git - mirror_qemu.git/commitdiff
curl: Check curl_multi_add_handle()'s return code
authorMax Reitz <mreitz@redhat.com>
Tue, 10 Sep 2019 12:41:36 +0000 (14:41 +0200)
committerMax Reitz <mreitz@redhat.com>
Mon, 16 Sep 2019 13:31:12 +0000 (15:31 +0200)
If we had done that all along, debugging would have been much simpler.
(Also, I/O errors are better than hangs.)

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20190910124136.10565-8-mreitz@redhat.com
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
block/curl.c

index c343c7ed3ddad205051d7e3b0196923bcb13e81e..f86299378e38d0e1c9f12fc3e69d06a55845217b 100644 (file)
@@ -882,7 +882,13 @@ static void curl_setup_preadv(BlockDriverState *bs, CURLAIOCB *acb)
     trace_curl_setup_preadv(acb->bytes, start, state->range);
     curl_easy_setopt(state->curl, CURLOPT_RANGE, state->range);
 
-    curl_multi_add_handle(s->multi, state->curl);
+    if (curl_multi_add_handle(s->multi, state->curl) != CURLM_OK) {
+        state->acb[0] = NULL;
+        acb->ret = -EIO;
+
+        curl_clean_state(state);
+        goto out;
+    }
 
     /* Tell curl it needs to kick things off */
     curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running);