cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
016a62
From a09766bbc8a4208fc0f62904cebec4022beba6b0 Mon Sep 17 00:00:00 2001
016a62
From: Max Reitz <mreitz@redhat.com>
016a62
Date: Tue, 19 Nov 2019 15:29:56 +0000
016a62
Subject: [PATCH 4/8] curl: Check completion in curl_multi_do()
016a62
MIME-Version: 1.0
016a62
Content-Type: text/plain; charset=UTF-8
016a62
Content-Transfer-Encoding: 8bit
016a62
016a62
RH-Author: Max Reitz <mreitz@redhat.com>
016a62
Message-id: <20191119153000.101646-4-mreitz@redhat.com>
016a62
Patchwork-id: 92516
016a62
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH 3/7] curl: Check completion in curl_multi_do()
016a62
Bugzilla: 1744602
016a62
RH-Acked-by: Maxim Levitsky <mlevitsk@redhat.com>
016a62
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
016a62
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
016a62
016a62
While it is more likely that transfers complete after some file
016a62
descriptor has data ready to read, we probably should not rely on it.
016a62
Better be safe than sorry and call curl_multi_check_completion() in
016a62
curl_multi_do(), too, just like it is done in curl_multi_read().
016a62
016a62
With this change, curl_multi_do() and curl_multi_read() are actually the
016a62
same, so drop curl_multi_read() and use curl_multi_do() as the sole FD
016a62
handler.
016a62
016a62
Signed-off-by: Max Reitz <mreitz@redhat.com>
016a62
Message-id: 20190910124136.10565-4-mreitz@redhat.com
016a62
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
016a62
Reviewed-by: John Snow <jsnow@redhat.com>
016a62
Signed-off-by: Max Reitz <mreitz@redhat.com>
016a62
(cherry picked from commit 948403bcb1c7e71dcbe8ab8479cf3934a0efcbb5)
016a62
Signed-off-by: Max Reitz <mreitz@redhat.com>
016a62
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
016a62
---
016a62
 block/curl.c | 14 ++------------
016a62
 1 file changed, 2 insertions(+), 12 deletions(-)
016a62
016a62
diff --git a/block/curl.c b/block/curl.c
016a62
index b3fe09f..8f31594 100644
016a62
--- a/block/curl.c
016a62
+++ b/block/curl.c
016a62
@@ -148,7 +148,6 @@ typedef struct BDRVCURLState {
016a62
 
016a62
 static void curl_clean_state(CURLState *s);
016a62
 static void curl_multi_do(void *arg);
016a62
-static void curl_multi_read(void *arg);
016a62
 
016a62
 #ifdef NEED_CURL_TIMER_CALLBACK
016a62
 /* Called from curl_multi_do_locked, with s->mutex held.  */
016a62
@@ -195,7 +194,7 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
016a62
     switch (action) {
016a62
         case CURL_POLL_IN:
016a62
             aio_set_fd_handler(s->aio_context, fd, false,
016a62
-                               curl_multi_read, NULL, NULL, state);
016a62
+                               curl_multi_do, NULL, NULL, state);
016a62
             break;
016a62
         case CURL_POLL_OUT:
016a62
             aio_set_fd_handler(s->aio_context, fd, false,
016a62
@@ -203,7 +202,7 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
016a62
             break;
016a62
         case CURL_POLL_INOUT:
016a62
             aio_set_fd_handler(s->aio_context, fd, false,
016a62
-                               curl_multi_read, curl_multi_do, NULL, state);
016a62
+                               curl_multi_do, curl_multi_do, NULL, state);
016a62
             break;
016a62
         case CURL_POLL_REMOVE:
016a62
             aio_set_fd_handler(s->aio_context, fd, false,
016a62
@@ -427,15 +426,6 @@ static void curl_multi_do(void *arg)
016a62
 
016a62
     qemu_mutex_lock(&s->s->mutex);
016a62
     curl_multi_do_locked(s);
016a62
-    qemu_mutex_unlock(&s->s->mutex);
016a62
-}
016a62
-
016a62
-static void curl_multi_read(void *arg)
016a62
-{
016a62
-    CURLState *s = (CURLState *)arg;
016a62
-
016a62
-    qemu_mutex_lock(&s->s->mutex);
016a62
-    curl_multi_do_locked(s);
016a62
     curl_multi_check_completion(s->s);
016a62
     qemu_mutex_unlock(&s->s->mutex);
016a62
 }
016a62
-- 
016a62
1.8.3.1
016a62