yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
4ec855
From 70c7a568e3c1384704228622990d6aaa2350e44e Mon Sep 17 00:00:00 2001
4ec855
From: Max Reitz <mreitz@redhat.com>
4ec855
Date: Tue, 19 Nov 2019 15:29:58 +0000
4ec855
Subject: [PATCH 6/8] curl: Report only ready sockets
4ec855
MIME-Version: 1.0
4ec855
Content-Type: text/plain; charset=UTF-8
4ec855
Content-Transfer-Encoding: 8bit
4ec855
4ec855
RH-Author: Max Reitz <mreitz@redhat.com>
4ec855
Message-id: <20191119153000.101646-6-mreitz@redhat.com>
4ec855
Patchwork-id: 92519
4ec855
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH 5/7] curl: Report only ready sockets
4ec855
Bugzilla: 1744602
4ec855
RH-Acked-by: Maxim Levitsky <mlevitsk@redhat.com>
4ec855
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4ec855
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
4ec855
4ec855
Instead of reporting all sockets to cURL, only report the one that has
4ec855
caused curl_multi_do_locked() to be called.  This lets us get rid of the
4ec855
QLIST_FOREACH_SAFE() list, which was actually wrong: SAFE foreaches are
4ec855
only safe when the current element is removed in each iteration.  If it
4ec855
possible for the list to be concurrently modified, we cannot guarantee
4ec855
that only the current element will be removed.  Therefore, we must not
4ec855
use QLIST_FOREACH_SAFE() here.
4ec855
4ec855
Fixes: ff5ca1664af85b24a4180d595ea6873fd3deac57
4ec855
Cc: qemu-stable@nongnu.org
4ec855
Signed-off-by: Max Reitz <mreitz@redhat.com>
4ec855
Message-id: 20190910124136.10565-6-mreitz@redhat.com
4ec855
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
4ec855
Reviewed-by: John Snow <jsnow@redhat.com>
4ec855
Signed-off-by: Max Reitz <mreitz@redhat.com>
4ec855
(cherry picked from commit 9abaf9fc474c3dd53e8e119326abc774c977c331)
4ec855
Signed-off-by: Max Reitz <mreitz@redhat.com>
4ec855
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
4ec855
---
4ec855
 block/curl.c | 17 ++++++-----------
4ec855
 1 file changed, 6 insertions(+), 11 deletions(-)
4ec855
4ec855
diff --git a/block/curl.c b/block/curl.c
4ec855
index de00ec8..f776615 100644
4ec855
--- a/block/curl.c
4ec855
+++ b/block/curl.c
4ec855
@@ -401,24 +401,19 @@ static void curl_multi_check_completion(BDRVCURLState *s)
4ec855
 }
4ec855
 
4ec855
 /* Called with s->mutex held.  */
4ec855
-static void curl_multi_do_locked(CURLSocket *ready_socket)
4ec855
+static void curl_multi_do_locked(CURLSocket *socket)
4ec855
 {
4ec855
-    CURLSocket *socket, *next_socket;
4ec855
-    CURLState *s = ready_socket->state;
4ec855
+    BDRVCURLState *s = socket->state->s;
4ec855
     int running;
4ec855
     int r;
4ec855
 
4ec855
-    if (!s->s->multi) {
4ec855
+    if (!s->multi) {
4ec855
         return;
4ec855
     }
4ec855
 
4ec855
-    /* Need to use _SAFE because curl_multi_socket_action() may trigger
4ec855
-     * curl_sock_cb() which might modify this list */
4ec855
-    QLIST_FOREACH_SAFE(socket, &s->sockets, next, next_socket) {
4ec855
-        do {
4ec855
-            r = curl_multi_socket_action(s->s->multi, socket->fd, 0, &running);
4ec855
-        } while (r == CURLM_CALL_MULTI_PERFORM);
4ec855
-    }
4ec855
+    do {
4ec855
+        r = curl_multi_socket_action(s->multi, socket->fd, 0, &running);
4ec855
+    } while (r == CURLM_CALL_MULTI_PERFORM);
4ec855
 }
4ec855
 
4ec855
 static void curl_multi_do(void *arg)
4ec855
-- 
4ec855
1.8.3.1
4ec855