cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-curl-Ensure-all-informationals-are-checked-for-compl.patch

05bba0
From 92a8426bb06ecb65af6fc6953e11870872bf52d1 Mon Sep 17 00:00:00 2001
05bba0
From: Richard Jones <rjones@redhat.com>
05bba0
Date: Thu, 11 Jun 2015 11:40:17 +0200
05bba0
Subject: [PATCH 17/30] curl: Ensure all informationals are checked for
05bba0
 completion
05bba0
05bba0
Message-id: <1434022828-13037-11-git-send-email-rjones@redhat.com>
05bba0
Patchwork-id: 65845
05bba0
O-Subject: [RHEL-7.2 qemu-kvm v3 PATCH 10/21] curl: Ensure all informationals are checked for completion
05bba0
Bugzilla: 1226684
05bba0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
05bba0
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
05bba0
05bba0
From: Matthew Booth <mbooth@redhat.com>
05bba0
05bba0
According to the documentation, the correct way to ensure all
05bba0
informationals have been returned by curl_multi_info_read is to loop
05bba0
until it returns NULL.
05bba0
05bba0
Signed-off-by: Matthew Booth <mbooth@redhat.com>
05bba0
Tested-by: Richard W.M. Jones <rjones@redhat.com>
05bba0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
05bba0
05bba0
Upstream-status: 1f2cead324436da25c3607f4b957f0198a01fc01
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 block/curl.c | 53 +++++++++++++++++++++++------------------------------
05bba0
 1 file changed, 23 insertions(+), 30 deletions(-)
05bba0
05bba0
diff --git a/block/curl.c b/block/curl.c
05bba0
index b19e632..41cf015 100644
05bba0
--- a/block/curl.c
05bba0
+++ b/block/curl.c
05bba0
@@ -248,46 +248,39 @@ static void curl_multi_check_completion(BDRVCURLState *s)
05bba0
 
05bba0
     /* Try to find done transfers, so we can free the easy
05bba0
      * handle again. */
05bba0
-    do {
05bba0
+    for (;;) {
05bba0
         CURLMsg *msg;
05bba0
         msg = curl_multi_info_read(s->multi, &msgs_in_queue);
05bba0
 
05bba0
+        /* Quit when there are no more completions */
05bba0
         if (!msg)
05bba0
             break;
05bba0
-        if (msg->msg == CURLMSG_NONE)
05bba0
-            break;
05bba0
 
05bba0
-        switch (msg->msg) {
05bba0
-            case CURLMSG_DONE:
05bba0
-            {
05bba0
-                CURLState *state = NULL;
05bba0
-                curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE,
05bba0
-                                  (char **)&state);
05bba0
-
05bba0
-                /* ACBs for successful messages get completed in curl_read_cb */
05bba0
-                if (msg->data.result != CURLE_OK) {
05bba0
-                    int i;
05bba0
-                    for (i = 0; i < CURL_NUM_ACB; i++) {
05bba0
-                        CURLAIOCB *acb = state->acb[i];
05bba0
-
05bba0
-                        if (acb == NULL) {
05bba0
-                            continue;
05bba0
-                        }
05bba0
-
05bba0
-                        acb->common.cb(acb->common.opaque, -EIO);
05bba0
-                        qemu_aio_release(acb);
05bba0
-                        state->acb[i] = NULL;
05bba0
+        if (msg->msg == CURLMSG_DONE) {
05bba0
+            CURLState *state = NULL;
05bba0
+            curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE,
05bba0
+                              (char **)&state);
05bba0
+
05bba0
+            /* ACBs for successful messages get completed in curl_read_cb */
05bba0
+            if (msg->data.result != CURLE_OK) {
05bba0
+                int i;
05bba0
+                for (i = 0; i < CURL_NUM_ACB; i++) {
05bba0
+                    CURLAIOCB *acb = state->acb[i];
05bba0
+
05bba0
+                    if (acb == NULL) {
05bba0
+                        continue;
05bba0
                     }
05bba0
-                }
05bba0
 
05bba0
-                curl_clean_state(state);
05bba0
-                break;
05bba0
+                    acb->common.cb(acb->common.opaque, -EIO);
05bba0
+                    qemu_aio_release(acb);
05bba0
+                    state->acb[i] = NULL;
05bba0
+                }
05bba0
             }
05bba0
-            default:
05bba0
-                msgs_in_queue = 0;
05bba0
-                break;
05bba0
+
05bba0
+            curl_clean_state(state);
05bba0
+            break;
05bba0
         }
05bba0
-    } while(msgs_in_queue);
05bba0
+    }
05bba0
 }
05bba0
 
05bba0
 static void curl_multi_do(void *arg)
05bba0
-- 
05bba0
1.8.3.1
05bba0